php Nginx 连接()失败错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15852884/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Nginx connect() failed error
提问by Hazem Hagrass
I don't know why I got this error every time I tried to open the page:
我不知道为什么每次尝试打开页面时都会出现此错误:
2013/04/06 17:52:19 [error] 5040#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8080"
回答by Hazem Hagrass
I resolved it, it was a configuration file issue, I added:
我解决了,是配置文件问题,我补充道:
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;
}
回答by ContextSwitch
For me the problem was my php-fpm service wasn't running. You can check it by running:
对我来说,问题是我的 php-fpm 服务没有运行。您可以通过运行来检查它:
service php-fpm status
and start it by running
并通过运行启动它
service php-fpm start
Sometimes php-fpm might have broken instances running, preventing a restart. This command is a clean way to clear them out and restart php-fpm
有时 php-fpm 可能会运行损坏的实例,从而阻止重新启动。此命令是清除它们并重新启动 php-fpm 的干净方法
killall -9 php-fpm; service php-fpm restart
回答by Lionel Morrison
I found I had this same issue with PHP7 running in Docker on a Debian Jessie (8.3) instance.
我发现我在 Debian Jessie (8.3) 实例上的 Docker 中运行 PHP7 时遇到了同样的问题。
- running command 'ps -aux' showed that php-fpm wasn't running
- running 'php-fpm -D' brought it up as deamonized process.
- Rerunning 'ps -aux' showed that php-fpm was indeed running
- Refreshing my test page showed me the servers PHP info.
- 运行命令 'ps -aux' 显示 php-fpm 没有运行
- 运行 'php-fpm -D' 将其作为非恶魔化进程。
- 重新运行 'ps -aux' 表明 php-fpm 确实在运行
- 刷新我的测试页面向我展示了服务器 PHP 信息。
Added 'php-fpm -D' to my start.sh script so that things started every time the container is loaded.
将“php-fpm -D”添加到我的 start.sh 脚本中,以便每次加载容器时启动。
Hope this helps someone.
希望这可以帮助某人。
回答by user3111020
update your configurations as mentioned before:
如前所述更新您的配置:
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;
}
but don't forget to restart both nginx server and php-fpm after updating
但不要忘记在更新后重新启动 nginx 服务器和 php-fpm
sudo /etc/init.d/nginx restart
sudo /etc/init.d/php-fpm restart
回答by Scott Z?
Use fastcgi_pass unix:/var/run/php5-fpm.sock; only nginx and php install same server. If nginx and php install in other server you must use fastcgi_pass ip server:port;
使用 fastcgi_pass unix:/var/run/php5-fpm.sock; 只有 nginx 和 php 安装相同的服务器。如果 nginx 和 php 安装在其他服务器上,则必须使用 fastcgi_pass ip server:port;