添加用户组
添加php-fpm用户
| 1
 | useradd -c php-fpm-user -g www -M php-fpm
 | 
c和c++编译器
| 1
 | yum install -y gcc gcc-c++
 | 
PHP扩展依赖
| 1
 | yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libicu-devel openldap-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
 | 
下载源码
| 1
 | wget http://cn2.php.net/get/php-5.6.31.tar.gz/from/this/mirror -O php-5.6.31.tar.gz  && tar zxvf php-5.6.31.tar.gz && cd php-5.6.31
 | 
编译指令
prefix自行修改
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 
 | ./configure --prefix=/home/server/php56\--with-libdir=lib64\
 --with-fpm-user=php-fpm\
 --with-fpm-group=www\
 --with-mysql=mysqlnd\
 --with-mysqli=mysqlnd\
 --with-pdo-mysql=mysqlnd\
 --with-openssl\
 --with-zlib\
 --with-curl\
 --with-gd\
 --with-zlib-dir=/usr/lib\
 --with-png-dir=/usr/lib\
 --with-jpeg-dir=/usr/lib\
 --with-gettext\
 --with-mcrypt\
 --with-mhash\
 --with-ldap\
 --with-freetype-dir=/usr/local/freetype\
 --enable-fpm\
 --enable-libxml\
 --enable-mysqlnd\
 --enable-opcache\
 --enable-pcntl\
 --enable-mbregex \
 --enable-mbstring\
 --enable-soap\
 --enable-zip\
 --enable-calendar\
 --enable-bcmath\
 --enable-exif\
 --enable-ftp\
 --enable-intl
 
 | 
php 配置结果
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 
 | config.status: creating php5.specconfig.status: creating main/build-defs.h
 config.status: creating scripts/phpize
 config.status: creating scripts/man1/phpize.1
 config.status: creating scripts/php-config
 config.status: creating scripts/man1/php-config.1
 config.status: creating sapi/cli/php.1
 config.status: creating sapi/fpm/php-fpm.conf
 config.status: creating sapi/fpm/init.d.php-fpm
 config.status: creating sapi/fpm/php-fpm.service
 config.status: creating sapi/fpm/php-fpm.8
 config.status: creating sapi/fpm/status.html
 config.status: creating sapi/cgi/php-cgi.1
 config.status: creating ext/phar/phar.1
 config.status: creating ext/phar/phar.phar.1
 config.status: creating main/php_config.h
 
 
 | 
配置php
| 12
 3
 4
 
 | make &&  make installcp -R ./sapi/fpm/php-fpm.conf /home/server/php56/etc/php-fpm.conf
 cp php.ini-development /home/server/php56/lib/php.ini
 cp -R ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm5.6
 
 | 
修改php-fpm.conf的侦听端口为9001
| 12
 
 | ; Note: This value is mandatory.  listen = 127.0.0.1:9001
 
 | 
设置php-fpm开机自动启动
| 12
 3
 
 | chmod +x /etc/init.d/php-fpm5.6chkconfig php-fpm5.6 on
 service php-fpm5.6 start
 
 | 
nginx
| 12
 3
 4
 
 | wget https://nginx.org/download/nginx-1.13.4.tar.gz -O nginx-1.13.4.tar.gz && tar -zxvf nginx-1.13.4.tar.gz && cd nginx-1.13.4 
 ./configure \
 --prefix=/home/server/nginx
 
 | 
nginx 配置结果
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 
 | nginx path prefix: "/home/server/nginx"nginx binary file: "/home/server/nginx/sbin/nginx"
 nginx modules path: "/home/server/nginx/modules"
 nginx configuration prefix: "/home/server/nginx/conf"
 nginx configuration file: "/home/server/nginx/conf/nginx.conf"
 nginx pid file: "/home/server/nginx/logs/nginx.pid"
 nginx error log file: "/home/server/nginx/logs/error.log"
 nginx http access log file: "/home/server/nginx/logs/access.log"
 nginx http client request body temporary files: "client_body_temp"
 nginx http proxy temporary files: "proxy_temp"
 nginx http fastcgi temporary files: "fastcgi_temp"
 nginx http uwsgi temporary files: "uwsgi_temp"
 nginx http scgi temporary files: "scgi_temp"
 
 | 
设置nginx服务开机自动启动
第一步,添加一个新文件,nginx.service
| 1
 | vi /lib/systemd/system/nginx.service
 | 
输入以下内容
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 
 | [Unit]Description=nginx
 After=network.target
 
 [Service]
 Type=forking
 ExecStart=/usr/local/nginx/sbin/nginx
 ExecReload=/usr/local/nginx/sbin/nginx -s reload
 ExecStop=/usr/local/nginx/sbin/nginx -s quit
 PrivateTmp=true
 
 [Install]
 WantedBy=multi-user.target
 
 | 
更改文件权限
| 1
 | chmod 745 /lib/systemd/system/nginx.service
 | 
设置开机自启动
| 1
 | systemctl enable nginx.service
 | 
赶紧开机试试看吧!
设置nginx开机自动启动(另一种)
| 12
 3
 
 | vi /etc/rc.local增加一行 /home/server/nginx/sbin/nginx
 chmod 755 rc.local
 
 | 
参考:http://blog.csdn.net/xlgen157387/article/details/52672988