成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術(shù)文章
文章詳情頁

nginx報(bào)錯(cuò)connect() failed(111: Connection refused)while connecting to up

瀏覽:22日期:2023-08-07 20:15:49

公司網(wǎng)站搬遷到新服務(wù)器后,發(fā)現(xiàn)站點(diǎn)訪問不了,network里面提示502,查看相關(guān)的server配置,感覺沒有什么問題,經(jīng)過測試發(fā)現(xiàn)txt、html、等非php文件能夠直接訪問,也就是php訪問不了,初步斷定有可能是php-fpm沒有安裝或者沒有啟動(dòng)導(dǎo)致。

首先判斷php-fpm是否已經(jīng)安裝,沒有安裝的情況就需要先安裝php-fpm,安裝可以參數(shù)相關(guān)資料。

確定好服務(wù)器已經(jīng)安裝了php-fpm之后,查看是否已經(jīng)啟動(dòng)或者直接重啟:

[root@xfzx /]# /usr/local/php/sbin/php-fpm start

啟動(dòng)完成后,重啟nginx:

[root@xfzx /]# service nginx restart

然后刷新網(wǎng)站頁面,但是并沒有成功,依然報(bào)錯(cuò)。

此時(shí)我們先在查看下錯(cuò)誤日志 error.log,發(fā)現(xiàn)里面都是清一色的報(bào)錯(cuò):

connect() failed (111: Connection refused) while connecting to upstream … fastcgi://127.0.0.1:9000 …

提示的意思就是說連接不上9000端口,這就奇怪了,其實(shí)在平時(shí)配置nginx的server里面,大部分應(yīng)該都是配置127.0.0.1:9000 作為分發(fā)端口。

現(xiàn)在需要查看一下是否有監(jiān)聽9000端口:

[root@xfzx/]# netstat -ant | grep 9000

發(fā)現(xiàn)并沒有監(jiān)聽到,但實(shí)際上我們的php-fpm已經(jīng)啟動(dòng),那現(xiàn)在怎么辦呢?我們?nèi)ゲ榭匆幌聀hp-fpm.conf里面的配置:

[root@xfzx /]# vim /usr/local/php/etc/php-fpm.conf

找到listen:

/tmp/php-cgi.sock

此時(shí)我們需要根據(jù)配置文件的listen地址做對(duì)應(yīng)的修改:

?location ~ \.php$ {? ? ? ? ? ? ? ? fastcgi_pass 127.0.0.1:9000;? ? ? ? ? ? ? ? fastcgi_index index.php;? ? ? ? ? ? ? ? fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;? ? ? ? ? ? ? ? include fastcgi_params;? ? ? ? }

改成:

location ~ \.php$ {? ? ? ? fastcgi_pass ? unix:/tmp/php-cgi.sock;? ? ? ? fastcgi_index ?index.php;? ? ? ? fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;? ? ? ? include ? ? ? ?fastcgi_params;? ? }

到此這篇關(guān)于nginx報(bào)錯(cuò)connect() failed(111: Connection refused)while connecting to upstream解決方法的文章就介紹到這了,更多相關(guān)nginx報(bào)錯(cuò)connect() failed內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Nginx