打开站点发现报错,bad gateway
查看NGINX日志error.log发现报错
1 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: tp5.samego.com, request: "GET /index.html HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxx.xxxxxxxxx.com"
问题何在?
我们先来看下nginx的配置内容
/usr/local/nginx/conf/vhost/xxxx.conf
server {
listen 80;
server_name tp5.samego.com;
access_log /var/logs/nginx/mydomain_access.log main;
error_log /var/logs/nginx/mydomain_error.log error;
set $root /home/www/xxxxxxxxxxxxxxxxxxxx;
location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
{
root $root;
}
location / {
root $root;
index index.html index.php;
if ( -f $request_filename) {
break;
}
if ( !-e $request_filename) {
rewrite ^(.*)$ /index.php/$1 last;
break;
}
}
location ~ .+\.php($|/) {
root $root;
fastcgi_pass 127.0.0.1:9000;#这里要注意了
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
include fastcgi_params;
}
}
然鹅并没有什么问题
那么是什么导致的php5-fpm一直无法监听9000端口?
来看下php.conf的配置
etc/php5/fpm/pool.d/www.conf
里面找到这样一段代码:
listen = /var/run/php5-fpm.sock 默认只有这个
注释这一行,添加
listen = 127.0.0.1:9000
listen = /var/run/php5-fpm.sock
保存后重新启动php5-fpm
/etc/init.d/php5-fpm restart
这时就可以正常访问了
解决!
原来只有保持NGINX和PHP监听一致即可!