[root@node1 ~]# yum install -y nginx
检查当前安装的PHP包php
[root@node1 ~]# yum install epel-release [root@node1 ~]# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
[root@node1 ~]# yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof
[root@node1 ~]# php --version
[root@node1 ~]# yum install --enablerepo=remi --enablerepo=remi-php56 php-fpm
[root@node2 ~]# vim /etc/php-fpm.d/www.conf
[root@node1 ~]# vim etc/php-fpm.conf 修改: user = nginx group = nginx 若是nginx用户不存在,那么先添加nginx用户 [root@node1 ~]# groupadd nginx [root@node1 ~]# useradd -g nginx nginx
[root@node1 ~]# vim /etc/nginx/nginx.conf
加入蓝色字体node
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
经过location指令,将全部以php为后缀的文件都交给127.0.0.1:9000来处理,而这里的IP地址和端口就是FastCGI进程监听的IP地址和端口。
fastcgi_param指令指定放置PHP动态程序的主目录,也就是$fastcgi_script_name前面指定的路径,这里是/usr/local/nginx/html目录,建议将这个目录与Nginx虚拟主机指定的根目录保持一致,固然也能够不一致。
fastcgi_params文件是FastCGI进程的一个参数配置文件,在安装Nginx后,会默认生成一个这样的文件,这里经过include指令将FastCGI参数配置文件包含了进来mysql
[root@node1 ~]# vim /usr/share/nginx/html/index.php 插入如下内容 <?php echo phpinfo(); ?>
启动php-fpm和nginxlinux
[root@node1 ~]# systemctl start php-fpm
[root@node1 ~]# systemctl start nginx
[root@node1 ~]# ps aux | grep -c php-fpm
查看监听的IP地址和端口相关信息nginx
[root@node1 ~]# netstat -antl|grep 9000
[root@node1 ~]# ps -ef|grep php-cgi
参考文档:sql
http://www.linuxidc.com/Linux/2010-05/26149.htm http://www.nginx.cn/231.html https://www.cnblogs.com/mangguoxiansheng/p/5967745.html https://www.cnblogs.com/txtfashion/p/3669524.html http://blog.51cto.com/ixdba/806622 http://www.thinkphp.cn/topic/48196.html