connect() failed (111: Connection refused) while connecting to upstream


配置好lamp后,在瀏覽器中運行程序后,出現上面的錯誤。

轉自:http://www.xuejiehome.com/blread-1828.html

I'm experiencing 502 gateway errors when accessing a PHP file in a directory (http://domain.com/dev/index.php), the logs simply says this:

2011/09/30 23:47:54 [error] 31160#0: *35 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: domain.com, request: \"GET /dev/ HTTP/1.1\", upstream: \"fastcgi://127.0.0.1:9000\", host: \"domain.com\"

The answer:

It sounds like you haven't started and configured backend for Nginx. Start php-fpm and add the following to nginx.conf, in http context:

server {
    listen 127.0.0.1;
    server_name localhost;
    error_log /var/log/nginx/localhost.error_log info;
    root /usr/local/nginx/html;
    location ~ \\.php$ {
        root           html;#此處和server下面root保持一致,默認為html
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME   /usr/local/nginx/html/$fastcgi_script_name;
        include        fastcgi_params;
    }
}

大概意思是你沒有啟動或者配置php-fpm.其中“/usr/local/nginx/html”為網站根目錄。

而我剛好是沒有啟動php-fpm,在終端運行“service php-fpm start”;

ok,正常運行了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM