Nginx+php更改了fastcgi_pass後面的地址php不能正常請求

來源:互聯網
上載者:User

標籤:list   res   rip   意思   nts   關閉   apple   inux   intel   

1.1.1 通過yum安裝Nginx和php,更改了Nginx裡面fastcgi_pass後的地址php不能正常請求
1.1.1.1 問題還原:
Nginx+php的伺服器位址是10.0.0.41/24
Nginx 安裝的是1.14 php安裝的是7.1,yum安裝過程不細講

nginx的location裡面的配置如下location ~ \.php$ {  root           /usr/share/nginx/html;  fastcgi_pass   10.0.0.41:9000;  fastcgi_index  index.php;  fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;  include        fastcgi_params;  }php-fpm設定檔更改的位置為:listen = 10.0.0.41:9000這個時候在/usr/share/nginx/html下面寫了一個php的測試頁[[email protected] ~]# cat /usr/share/nginx/html/test.php <?phpphpinfo();?>

然後在瀏覽器裡面訪問10.0.0.41/test.php

1.1.1.2 剖析與解決:
然後分析錯誤502可能的原因:這個裡面的bad geteway不是字面上的意思,這個地方基本上都是php-fpm請求的時候不正常,然後就開始著後段的錯誤
查看訪問日誌,和錯誤記錄檔

訪問日誌:10.0.0.1 - - [30/Aug/2018:01:46:02 -0400] "GET /test.php HTTP/1.1" 200 95137 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" "-"10.0.0.1 - - [30/Aug/2018:02:18:05 -0400] "GET /test.php HTTP/1.1" 502 575 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" "-"錯誤記錄檔:2018/08/30 02:18:05 [error] 9609#9609: *4 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 10.0.0.1, server: localhost, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://10.0.0.41:9000", host: "10.0.0.41"意思就是請求這個主機的10.0.0.41:9000連接埠失敗

然後就去觀看防火牆和selinux是否關閉,9000連接埠是否正常,發現防火牆和selinux都是關閉的,9000連接埠也正常監聽。
這個時候就想肯定是php-fpm轉寄又問題,就開始去找設定檔,看看是不是監聽的有問題
vim /etc/php-fpm.d/www.conf
在裡面搜尋listen監聽相關的內容,找到一個listen.allowed_clients 的語句
listen.allowed_clients = 127.0.0.1,看到這的時候我就明白可能是php設定檔裡面我們要允許clients可以通過這個地址訪問
更改為listen.allowed_clients = 10.0.0.41
儲存重啟php服務後測試發現正常。問題得以解決。

Nginx+php更改了fastcgi_pass後面的地址php不能正常請求

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.