【发布时间】:2014-10-17 10:08:03
【问题描述】:
这是我的设置细节
Nginx.conf
user nginx;
worker_processes 8;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 4096;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
我的 conf 文件,文件名默认位于可用站点和已启用站点中
server {
server_name www.subdomain.mywebsite.com subdomain.mywebsite.com;
access_log /srv/www/subdomain.mywebsite.com/logs/access.log;
error_log /srv/www/subdomain.mywebsite.com/logs/error.log;
root /srv/www/subdomain.mywebsite.com/public_html;
location / {
index index.html index.htm index.php;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /srv/www/subdomain.mywebsite.com/public_html$fastcgi_script_name;
}
}
当我通过我的域运行 html 文件时,它工作正常。
但是如果我去php文件,比如例子
subdomain.mywebsite.com/info.php
它给出了 nginx 的 502 bad gateway 错误
出现问题时,Php5-fpm 正在运行
root@ubuntu:/etc/nginx/sites-available# service php5-fpm status
php5-fpm start/running, process 12196
【问题讨论】:
-
您是否尝试过通过套接字连接到 PHP-FPM?比如:
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; -
@ajtrichards_wales 我试过了,同样的 502 badgateway