centos7 安装LNMP(php7)之 nginx php-fpm yum安装以及配置文件修改
PHP7.1.6整体参考
https://www.zhihu.com/question/50615606/answer/145699091
http://www.bubuko.com/infodetail-2128641.html
3.rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
4.yum install nginx
service nginx start
5.
# find / -name nginx.conf
/etc/nginx/nginx.conf
在nginx.conf中最后一行看到
include /etc/nginx/conf.d/*.conf;
所以找到/etc/nginx/conf.d/default.conf;
在location下面加上同级
location ~ \.php$ {
root /var/www/html; #指定php的根目录
fastcgi_pass 127.0.0.1:9000;#php-fpm的默认端口是9000
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
6.nginx -t如果没有报错,报错去修改错误
7./usr/sbin/nginx -s reload 重启nginx服务
然后在/var/www/html建立index.php
<?php
phpinfo();
8.检查发现php-fpm没有监听
发现总是无法解析,所以要配置php-fpm
9./opt/runtime/php/sbin/php-fpm
10.找到php-fpm.conf.default改成php-fpm.fonf
11.将www.conf.defualt改成www.conf
12.启动php-fpm
/opt/runtime/php/sbin/php-fpm
13.查看php-fpm是否打开
netstat -npa | grep 9000
14.在nginx指向文件写下index.php /var/www/html/index.php
<?php
phpinfo();