php-fpm 启动后没有监听端口9000

3,116 阅读1分钟

情况:nginx访问报错502。

服务器:ubuntu。

先查看php-fpm是否启动:

ps -ef | grep php-fpm

一般来说php-fpm是默认监听9000端口的,查看是否监听:

lsof -i:9000

这一步发现php-fpm未监听9000端口。

查看vim /usr/local/php/etc/php-fpm.conf文件(根据情况每个人安装位置可能不一样)

发现listen = /tmp/php-cgi.sock。(我后来改成/data/php-cgi.sock了)

修改nginx下的sites配置

location ~ .php$ {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param APPLICATION_ENV production;

include fastcgi_params;

}

location ~ .php$ {

fastcgi_pass unix:/var/run/php5-fpm.sock;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME documentrootdocument_rootfastcgi_script_name;

include fastcgi_params;

}

重启php-fpm与nginx后,访问成功。