lnmp 搭建後,nginx下php檔案404但是html檔案正常訪問【已解決】

來源:互聯網
上載者:User

標籤:img   usermod   tps   fail   www   php   err   overflow   png   

今天遇到 了如題的問題。

上網查了很多資料

最終是在這個連結 裡 找到了能解決我的問題的方法

https://stackoverflow.com/questions/23443398/nginx-error-connect-to-php5-fpm-sock-failed-13-permission-denied/23596317

出現這種問題,可能每個人的情況 不太一樣。

我總結出以下兩點,可以朝這兩個方向去解決問題:

   1.   nginx.conf 檔案 裡,root 指令 和 fastcgi_param 指令  與 你要訪問的檔案 的路徑是否一致。

 

   2. 就是許可權問題。

    可以通過nginx的 error.log查看 ,

  

 connect() to unix:/run/php/php5.6-fpm.sock failed (13: Permission denied)

 

  如果有以上這段錯誤提示,說明就是 php-fpm.sock 許可權問題。

  可以通過php-fpm 的 www.conf  檔案, 查看到 php-fpm的 所屬組和所屬使用者  

user=www-data // 這就是所屬使用者group=www-data // 這就是所屬組

       然後通過 修改 nginx 使用者組來解決許可權問題 

sudo usermod -aG www-data nginx

     最後 重啟 nginx 服務 就Ok 了 

lnmp 搭建後,nginx下php檔案404但是html檔案正常訪問【已解決】

聯繫我們

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