【发布时间】:2013-01-26 16:23:40
【问题描述】:
我正在努力让 nginx 启动并使用 php5-fpm 运行。我觉得这是我忽略了一个小细节,所以我休息了几天,然后又回来了。今晚又搞砸了几个小时,但无济于事。
无论如何,问题是:我已经启动并运行了 nginx。它似乎可以正确地提供网页。例如,http://www.shidenadvanced.com 的基本网站服务就很好。但是,我拥有的位于http://www.shidenadvanced.com/test.php 的 php 测试返回空白。以前它作为 502 错误网关返回。
通过我的研究,我了解到这意味着它无法通过 php-fpm 正确路由它。不是 100%。
这是我的 /sites-available/config:
server {
server_name www.shidenadvanced.com shidenadvanced.com;
access_log /srv/sites/shidenadvanced/logs/access.log;
error_log /srv/sites/shidenadvanced/logs/error.log;
root /srv/sites/shidenadvanced/www;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
#location ~ \.php$ {
# try_files $uri =404;
# include /etc/nginx/fastcgi_params;
# fastcgi_pass unix:/var/run/php-fpm5.sock;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /srv/sites/shidenadvanced/www$fastcgi_script_name;
#}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
除此之外,我已经单独保留了大部分设置。不完全确定发生了什么。有人能解释一下吗?
【问题讨论】:
-
您的错误日志中有任何内容吗?
/var/run/中是否也存在套接字? -
错误日志的输出: 2013/01/26 05:02:52 [crit] 3647#0: *20 connect() to unix:/var/run /php-fpm5.sock 连接到上游时失败(2:没有这样的文件或目录),客户端:74.110.180.71,服务器:www.shidenadvanced.com,请求:“GET /test.php HTTP/1.1”,上游: "fastcgi://unix:/var/run/php-fpm5.sock:", host: "www.shidenadvanced.com" -- 这是最近的一行。但是那个 php-fpm5.sock 确实存在。 /var/run/php5-fpm.sock,即
-
愚蠢的问题,只是为了确定:你提到你已经启动并运行了 nginx,你是否也启动(和配置)了 php-fpm 守护进程?
-
我很确定我做到了。正如我所提到的,我有文件 /var/run/php5-fpm.sock 。我还查看了 /etc/php5/fpm/pool.d/www.conf 以确保它正在侦听该套接字。当我输入“service php5-fpm status”时,它返回它正在运行。我试过多次重启 php5-fpm 和 nginx。
-
你解决了吗?