Background problem
Configuring nginx + php service, I found the site to open html, php file to open the display 502, generally this is a php did not start ah what the cause can not be resolved php file properly.
Cause Analysis
Because nginx php file is parsed to fastcgi_pass to deal with the default general fastcgi_pass There are two ways to parse php, one is the common tcp 9000 port is listening, here only resolve the tcp.
netstat -ntlp View 9000 port is not listening, do not listen on the default 9000
port, and is listening/tmp/php-cgi-56.sock
[root@localhost pazzn]# netstat -ntlp ###没有9000端口监听 Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 13031/nginx: master tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1425/sshd tcp 0 0 0.0.0.0:888 0.0.0.0:* LISTEN 13031/nginx: master tcp 0 0 0.0.0.0:8888 0.0.0.0:* LISTEN 3818/python tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3467/master tcp6 0 0 :::22 :::* LISTEN 1425/sshd tcp6 0 0 ::1:25 :::* LISTEN 3467/master tcp6 0 0 :::3306 :::* LISTEN 3401/mysqld
solution
1. Find/php.conf
[root@localhost ~]# find / -name php-fpm.conf /www/server/php/56/etc/php-fpm.conf
[root@localhost ~]#vi /www/server/php/56/etc/php-fpm.conf
2. ;
Comment out the sock listening mode, increasing the listening port 9000
[global] pid = /www/server/php/56/var/run/php-fpm.pid error_log = /www/server/php/56/var/log/php-fpm.log log_level = notice [www] #listen = /tmp/php-cgi-56.sock listen = 9000 listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = www listen.group = www listen.mode = 0666 user = www group = www pm = dynamic pm.status_path = /phpfpm_56_status pm.max_children = 80 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 20 request_terminate_timeout = 100 request_slowlog_timeout = 30 slowlog = var/log/slow.log
3. Restart php, php file parsing perfect open
[root@localhost ]# systemctl restart php-fpm-56.service
Note: nginx.conf must first ensure that the configuration file is correct, oh.
Reference link: https: //blog.csdn.net/moshowgame/article/details/84135977