centos 6.5 安装lnmp(linux+nginx+mysql+php)
参考:http://www.cnblogs.com/AloneSword/archive/2013/03/18/2966750.html (总结并简要)
一安装cmake
wget -c http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
tar zxvf cmake-2.8.5.tar.gz
cd cmake-2.8.5
.boostarp (有这个命令就执行,否则就跳过)
make
make install
cmake --version
二安装mysql
yum -y install gcc libxml2-dev curl screen \
libpng12-dev autoconf libpcre3-dev make bzip2 \
libevent-dev patch libjpeg62-dev libcurl4-openssl-dev \
libfreetype6-dev g++ libtool libncurses5-dev psmisc lrzsz \
openssl openssl-devel ncurses ncurses-devel
# 创建用户和组
groupadd mysql
useradd -g mysql -s /usr/sbin/nologin mysql
# 创建安装目录
mkdir /usr/local/ mysql
# 创建数据库目录
mkdir /usr/local/ mysql/data
# 解压
tar -zxvf mysql-5.5.17.tar.gz
cd mysql-5.5.17
# 编译及安装mysql
# cmake编译:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
PS: cmake的时候,参数可以不用那么多,只要一个-DCMAKE_INSTALL_PREFIX=/usr/local/mysql就行了,我们可以在 my.cnf里面配置。[mysqld]中的内容,看看你copy后的my.cnf有没有这些设置,有就不用了在设置了。
或
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_unicode_ci \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0
# 安装mysql
make && make install
# 复制配置文件
cp support-files/my-medium.cnf /usr/local/mysql/my.cnf
或
cp support-files/my-medium.cnf /etc/my.cnf
# 设置权限
chmod +x /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data
# 配置开机自启动
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfg mysqld on
# 修改my.cnf配置
vim /etc/my.cnf
# [mysqld] 添加:
datadir=/usr/local/mysql/data
default-storage-engine=MyISAM
# 以下可选:
log-error =/usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
tmpdir = /tmp
# 初始化数据库
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &
# 启动MySQL
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
或者:
/etc/init.d/mysql start (service mysql start)
# 测试MySQL是否启动
# 1)查看是否有进程mysql
ps -ef | grep mysql
# 2)查看端口是否运行
netstat -tnl | grep 3306
# 3)读取mysql版本信息
/usr/local/mysql/bin/mysqladmin version
初使密码
#> service mysqld stop
#>mysqld_safe --skip-grant-tables &
输入 mysql -uroot -p 回车进入
或
编辑my.cnf
在[mysqld] 配置部分添加一行
skip-grant-tables
>use mysql;
> update user set password=PASSWORD("newpass")where user="root";
更改密码为 newpassord
> flush privileges; 更新权限
> quit 退出
service mysqld restart
mysql -uroot -p新密码进入
或
//启动mysql server在后台运行
#./bin/mysqld_safe --user=mysql &
设置密码
# ./bin/mysqladmin -u root password 'passwd'
//进入mysql
# ./bin/mysql -u root -p
二安装php
参考:http://www.phperz.com/article/14/1207/39774.html
准备:
yum -y install gcc automake autoconf libtool make
./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt \
--enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath \
--enable-inline-optimization --with-bz2 --with-zlib --enable-sockets \
--enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \
--with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli \
--with-gd --with-jpeg-dir
cp php.ini.production /usr/local/php/etc
启动
/usr/local/php/sbin/php-fpm -t/usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini -y /usr/local/php/etc/php-fpm.conf -t报错:
configure: error: Please reinstall the BZip2 distribution
解决
yum -y install bzip2 bzip2-devel
报错:
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
解决
yum -y install libcurl licurl-devel
报错:
/usr/local/src/php-5.3.8/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
make: *** [ext/phar/phar.php] Error 127
解决:
1.在/etc/ld.so.conf中加一行/usr/local/lib,
2.然后运行/sbin/ldconfig
还不行再加一个
find / -name "libmysqlclient.so.18"
echo "/usr/local/mysql/lib/" >> /etc/ld.so.conf
tail -1 /etc/ld.so.conf
ldconfig
这样就ok了它就能找到库文件了
添加环境变量
vim /etc/profile
export PATH="$PATH:/usr/local/php/sbin"
启动服务
/usr/local/php/sbin/php-fpm
报错:
三安装nginx
安装Nginx时报错
./configure: error: the HTTP rewrite module requires the PCRE library.
安装pcre-devel解决问题
yum -y install pcre-devel
加入环境变量
vim /etc/profile
export PATH="$PATH:/usr/local/nginx/sbin"
配置:
#vim /usr/local/nginx/conf/fastcgi_params
if ($fastcgi_script_name ~ "\..*\/.*\.php") {
return 404;
}
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;#脚本文件请求的路径
fastcgi_param QUERY_STRING $query_string; #请求的参数;如?app=
fastcgi_param REQUEST_METHOD $request_method; #请求的动作(GET,POST)
fastcgi_param CONTENT_TYPE $content_type; #请求头中的Content-Type字段
fastcgi_param CONTENT_LENGTH $content_length; #请求头中的Content-length字段。 fastcgi_param SCRIPT_NAME $fastcgi_script_name; #脚本名称
fastcgi_param REQUEST_URI $request_uri; #请求的地址不带参数
fastcgi_param DOCUMENT_URI $document_uri; #与$uri相同。
fastcgi_param DOCUMENT_ROOT $document_root; #网站的根目录。在server配置中root指令中指定的值
fastcgi_param SERVER_PROTOCOL $server_protocol; #请求使用的协议,通常是HTTP/.0或HTTP/1.1。 fastcgi_param GATEWAY_INTERFACE CGI/1.1;#cgi 版本
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;#nginx 版本号,可修改、隐藏 fastcgi_param REMOTE_ADDR $remote_addr; #客户端IP
fastcgi_param REMOTE_PORT $remote_port; #客户端端口
fastcgi_param SERVER_ADDR $server_addr; #服务器IP地址
fastcgi_param SERVER_PORT $server_port; #服务器端口
fastcgi_param SERVER_NAME $server_name; #服务器名,域名在server配置中指定的server_name #fastcgi_param PATH_INFO $path_info;#可自定义变量 # PHP only, required if PHP was built with --enable-force-cgi-redirect
#fastcgi_param REDIRECT_STATUS ; 在php可打印出上面的服务环境变量
如:echo $_SERVER['REMOTE_ADDR']
参考:http://www.cnblogs.com/rnckty/p/4832213.html
http://blog.hackroad.com/operations-engineer/linux_server/1453.html
centos 6.5 安装lnmp(linux+nginx+mysql+php)的更多相关文章
- centos7安装Lnmp(Linux+Nginx+MySql+Php+phpMyAdmin+Apache)
centos7安装Lnmp(Linux+Nginx+MySql+Php)及Apache Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx是一个高性能的HTTP和反向代理服务器,Ng ...
- centos6服务器YUM安装LNMP(LINUX+NGINX+MYSQL+PHP)
之前都用的lamp,这次配置一个lnmp来看看,试试Nginx是不是好用 关闭SELINUXvi /etc/selinux/config#SELINUX=enforcing #注释掉#SELINUXT ...
- 安装lnmp(linux nginx mysql php)
下载或者在云盘里找lnmp1.2-full.tar.gz 用 tar -zxvf lnmp1.2-full.tar.gz解压 进入 ,运行./install.sh安装.根据提示. 如果出现yum锁定, ...
- 阿里云Linux CentOS8.1 64位服务器安装LNMP(Linux+Nginx+MySQL+PHP)
LNMP环境和软件版本: 名称 版本号 查询命令 Linux系统 CentOS Linux release 8.1.1911 (Core) cat /etc/redhat-release Nginx ...
- LNMP(linux+nginx+mysql+php)服务器环境配置【转载】
本文转载自 园友David_Tang的博客,如有侵权请联系本人及时删除,原文地址: http://www.cnblogs.com/mchina/archive/2012/05/17/2507102.h ...
- LNMP(linux+nginx+mysql+php)服务器环境配置
一.简介 Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为 “engine X”, 是一个高性能的HTTP和反向代理服务器,同时也是一个IMAP/POP3/SMTP 代理服 ...
- 阿里云Linux CentOS8.1 64位服务器安装LNMP(Linux+Nginx+MySQL+PHP) 并发调试之Nginx配置
搭建好LNMP环境之后,接着要考虑的就是整个系统的并发能力了. 一.Nginx的配置 Nginx有很好的并发能力.但是要想使它的并发能力能够施展出来,需要在初步安装好的Nginx上做一些配置.主要需要 ...
- centos 7 搭建 LNMP ( Linux+Nginx+MySQL+PHP )
操作系统 | CentOS Linux release 7.6.1810 (Core) [root@localhost ~# cat /etc/redhat-release CentOS Linux ...
- LNMP(Linux+Nginx+MySQL+PHP)centos6.4安装
nginx命令 停止nginx服务:# /etc/init.d/nginx stop 启动nginx服务:# /etc/init.d/nginx start 编辑nginx配置文件:# vim /et ...
随机推荐
- (剑指Offer)面试题19:二叉树的镜像
题目: 操作给定的二叉树,将其变换为源二叉树的镜像. 二叉树的定义如下: struct TreeNode{ int val; TreeNode* left; TreeNode* right; }; 输 ...
- Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- eclipse提示servlet不存在 的解决办法
在以前的版本中,Tomcat的common/lib目录下有一个名为servlet-api.jar的包,把它拷贝至你的java安装目录下jre/lib/ext下就可以了. 如果是:tomcat6就在To ...
- PostgreSQL中使用枚举类型
https://wiki.postgresql.org/wiki/Enum 建立enum: pgsql=# CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy' ...
- 常用CSS3效果:用text-shadow做CSS3 文字描边
思路: 利用CSS3的text-shadow属性,对文字的四个边均用阴影. 最终效果: 单纯的为了实现效果.未作任何美化. 实现代码: HTML: <div>文字描边效果</div& ...
- CentOS 6.5 源码安装MySQL5.6
1:下载安装cmake (mysql5.5以后是通过cmake来编译的) #http://download.csdn.net/detail/csxuedn/7976005 #wget http://w ...
- HTML之一语言代码
HTML的lang属性可用于网页或部分网页的语言.这对搜索引擎和浏览器是有帮助的. 同时也可以是指HTTP Header中的Accept-Language/Content-Language. ISO ...
- Android Studio中导入第三方库
之前开发Android都是使用的eclipse,近期因为和外国朋友Timothy一起开发一款应用,他是从WP平台刚切换使用Android的,使用的开发环境时Android Studio,为了便于项目的 ...
- /bin/bash: line 0: fg: no job control一般解决方法
測试版本号:CDH5.0,(Hadoop2.3) 在使用windows调用Hadoop yarn平台的时候,一般都会遇到例如以下的错误: 2014-05-28 17:32:19,761 WARN or ...
- ASCII码对应表
chr(9) tab空格 chr(10) 换行 chr(13) 回车 Chr(13)&chr(10) 回车换行 chr(32) 空格符 ...