centos7 nginx 支持php

参考 这里

php的配置文件在这里:

[root@c7 capritools-tv]#
[root@c7 capritools-tv]# cat /etc/nginx/conf.d/php.conf
server {
listen 8090;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php{  
         root           /ngroot/php;  
         fastcgi_pass   127.0.0.1:9000;  
         fastcgi_index  index.php;  
         fastcgi_param  SCRIPT_FILENAME
document_root$fastcgi_script_name;
include fastcgi_params;
}

}

输入 http://192.168.10.88:8090/phpinfo.php 来访问。

9000端口没有被监听到,服务没启动,会有如下错误:

502 Bad Gateway

参考这里解决。

[root@c7 capritools-tv]# ps auxww | grep php5-cgi
root 7129 0.0 0.0 112660 956 pts/0 S+ 22:41 0:00 grep –color=auto php5-cgi

必须监听9000端口
[root@c7 capritools-tv]# netstat -an | grep 9000
[root@c7 capritools-tv]# netstat -an | grep 9003

启动服务的命令
[root@c7 capritools-tv]# service php-fpm start
Redirecting to /bin/systemctl start php-fpm.service

[root@c7 capritools-tv]# netstat -an | grep 9003

这时候才有效果
[root@c7 capritools-tv]# netstat -an | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
[root@c7 capritools-tv]#

phpinfo.php的写法:

猜你喜欢

转载自blog.csdn.net/commshare/article/details/76165112