解决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
版权声明:本文为博主原创文章,转载请附上博文链接!

posted on   剩余价值  阅读(1565)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示