Nginx设计的初衷是提供一种快速、高效、多并发的Web服务软件。在静态页面的处理上,Nginx较Apache更胜一筹;但是在动态页面的处理上,Nginx并不比Apache有优势。
[root@lizhipenglinux01 src]# ps aux|grep mysql 检查mysql服务有没有启动,如果有请停止服务,service mysql stop
root 5035 0.0 0.0 112676 980 pts/0 R+ 18:22 0:00 grep --color=auto mysql
[root@lizhipenglinux01 src]# rm -rf /usr/local/mysql
[root@lizhipenglinux01 src]# rm -rf /etc/init.d/mysqld 删除启动脚本
[root@lizhipenglinux01 src]# vim /etc/my.cnf 配置暂时保留
[root@lizhipenglinux01 src]# pwd 进入目录
/usr/local/src
[root@lizhipenglinux01 src]# wget ....^C wget下载包
[root@lizhipenglinux01 src]# tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz 解压
[root@lizhipenglinux01 src]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/ 更改名字,确保没有出现mysql
apache2/ apr/ bin/ games/ lib/ libexec/ php/ sbin/ src/
apache2.4/ apr-util/ etc/ include/ lib64/ mariadb/ php7/ share/
[root@lizhipenglinux01 src]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql 更改名字,确保没有出现mysql
[root@lizhipenglinux01 src]# ls /usr/local/mysql/
bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files
[root@lizhipenglinux01 mysql]# ls /data/ 创建目录,之前已经创建了
mariadb mysql wwwroot
[root@lizhipenglinux01 mysql]# id mysql 创建用户mysql,之前已经创建了
uid=1008(mysql) gid=1008(mysql) 组=1008(mysql)
[root@lizhipenglinux01 mysql]# ls
bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files
[root@lizhipenglinux01 mysql]# rm -rf /data/mysql/* 把mysql里面的东西清空掉
[root@lizhipenglinux01 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
[root@lizhipenglinux01 mysql]# echo $?
0
编辑配置文件
[root@lizhipenglinux01 mysql]# cp support-files/mysql.server /etc/init.d/mysqld 拷贝启动脚本
[root@lizhipenglinux01 mysql]# vim /etc/init.d/mysqld
[root@lizhipenglinux01 mysql]# chkconfig --add mysqld mysqld加入到服务列表
[root@lizhipenglinux01 mysql]# chkconfig mysqld on 开机自启
[root@lizhipenglinux01 mysql]# service mysql stop
Redirecting to /bin/systemctl stop mysql.service
[root@lizhipenglinux01 mysql]# service mysqld stop
Shutting down MySQL.. SUCCESS!
[root@lizhipenglinux01 mysql]# service mysqld start
Starting MySQL. SUCCESS!
[root@lizhipenglinux01 src]# cd php-5.6.30/
[root@lizhipenglinux01 php-5.6.30]# pwd
/usr/local/src/php-5.6.30
[root@lizhipenglinux01 php-5.6.30]# make clean 之前编译过的文件全部删掉
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp5.la sapi/cli/php sapi/cgi/php-cgi libphp5.la modules/* libs/* 删完以后处于刚刚解压的状态,之后编译针对Nginx的PHP
[root@lizhipenglinux01 php-5.6.30]# ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
checking for cURL in default path... not found 安装报错,少curl
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
[root@lizhipenglinux01 php-5.6.30]# yum install libcurl-devel
[root@lizhipenglinux01 php-5.6.30]# ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl 再来一遍
[root@lizhipenglinux01 php-5.6.30]# make && make install
[root@lizhipenglinux01 php-5.6.30]# ls /usr/local/php-fpm/ 比原来的php多了一个sbin,var
bin etc include lib php sbin var
[root@lizhipenglinux01 php-5.6.30]# ls /usr/local/php/
bin etc include lib php
[root@lizhipenglinux01 php-5.6.30]# /usr/local/php-fpm/sbin/php-fpm -t 检查有没有错误
[10-Mar-2018 21:05:12] ERROR: failed to open configuration file ‘/usr/local/php-fpm/etc/php-fpm.conf‘: No such file or directory (
[10-Mar-2018 21:05:12] ERROR: failed to load configuration file ‘/usr/local/php-fpm/etc/php-fpm.conf‘
[10-Mar-2018 21:05:12] ERROR: FPM initialization failed
[root@lizhipenglinux01 php-5.6.30]# ls /usr/local/php
php/ php7/ php-fpm/
[root@lizhipenglinux01 php-5.6.30]# ls /usr/local/php-fpm/etc/
pear.conf php-fpm.conf.default
[root@lizhipenglinux01 php-5.6.30]# cp php.ini-production /usr/local/php-fpm/etc/php.ini 拷贝过去,并改名为php.ini
[root@lizhipenglinux01 etc]# ls
pear.conf php-fpm.conf.default php.ini
[root@lizhipenglinux01 etc]# vim php-fpm.conf
[global] 全局参数
pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log
[www] 模块名字
listen = /tmp/php-fcgi.sock 监听地址
#listen = 127.0.0.1:9000
listen.mode = 666 当监听的是socket的时候,该语句才会生效
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
[root@lizhipenglinux01 etc]# cd /usr/local/src/php
php-5.6.30/ php-7.1.6/ phpredis-develop/
[root@lizhipenglinux01 etc]# cd /usr/local/src/php-5.6.30/ 进入源码目录,拷贝启动脚本
[root@lizhipenglinux01 php-5.6.30]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@lizhipenglinux01 php-5.6.30]# chmod 755 /etc/init
init.d/ inittab
[root@lizhipenglinux01 php-5.6.30]# chmod 755 /etc/init.d/php-fpm
[root@lizhipenglinux01 php-5.6.30]# chkconfig --add php-fpm
[root@lizhipenglinux01 php-5.6.30]# chkconfig php-fpm on
[root@lizhipenglinux01 php-5.6.30]# service php-fpm start 启动失败,原因是有一个用户不存在
Starting php-fpm [10-Mar-2018 21:49:01] ERROR: [pool www] cannot get uid for user ‘php-fpm‘
[10-Mar-2018 21:49:01] ERROR: FPM initialization failed
failed
[root@lizhipenglinux01 php-5.6.30]# useradd php-fpm
[root@lizhipenglinux01 php-5.6.30]# service php-fpm start
Starting php-fpm done
[root@lizhipenglinux01 php-5.6.30]# ps aux |grep php-fpm
[root@lizhipenglinux01 php-5.6.30]# ls -l /tmp/php-fcgi.sock
srw-rw-rw- 1 root root 0 3月 10 21:50 /tmp/php-fcgi.sock 666