解決PHP7無法監聽9000端口問題/502錯誤解決辦法


問題背景

昨晚幫配置nginx+php服務的時候,發生了一個奇怪的事情
netstat -anp|grep 9000查看9000端口,一直沒有監聽,於是nginx無法通過fastcgi來代理php請求。一直都是502

原因分析

因為php7升級了配置,默認不再監聽9000端口了,監聽的是/run/php/php7.0-fpm.sock

解決方案

找到/etc/php/7.0/fpm/pool.d/www.conf,用;注釋掉sock監聽的方式,增加9000端口監聽
;listen = /run/php/php7.0-fpm.sock
listen = 9000
1
2
重啟php7,可以service php7.0-fpm restart或者/etc/init.d/php7.0-fpm restart的方式重啟。

檢查nginx配置,看下是正確

server{
listen 80;
server_name localhost;
root "/www/xxxx/";
location / {
index index.php index.html index.htm;
autoindex off;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
---------------------
作者:Moshow鄭鍇
來源:CSDN
原文:https://blog.csdn.net/moshowgame/article/details/84135977
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM