nginx串連php-fpm sock檔案失敗502

來源:互聯網
上載者:User

標籤:ar   io   使用   for   on   檔案   問題   bs   cti   

今天把vps上php5.3升級到了php5.4,我採用的是nginx+php-fpm的架構,nginx通過php-fpm的socks檔案來串連。
結果報錯:
connect() to unix:/tmp/php-cgi.sock failed (13: Permission denied) while connecting to upstream

我檢查了一下 /tmp/php-cgi.sock 發現該檔案擁有者是root,而nginx和php-fpm都是www使用者來啟動並執行,按理講,這個sock檔案也應該是www才對。

後來發現在php-fpm.conf中有這麼一段配置:
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0660
;listen.owner = www
;listen.group = www
;listen.mode = 0660

很奇怪,按照說明,預設應該使用 user和group配置項來設定許可權,但實際上沒有。不管怎麼樣,通過手動指定一下這裡的配置就解決問題了。
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = www
listen.group = www
;listen.mode = 0660

nginx串連php-fpm sock檔案失敗502

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.