Ngnix 搭配 PHP-FPM 噴 php5-fpm.sock failed (13: Permission denied)

nginx-logo

Nginx 搭配 PHP-FPM 已經是架設 PHP 伺服器基本入門款了,這次升級 CentOS 機器完後,發現 Log 一直噴出底下訊息

nginx error connect to php5-fpm.sock failed (13: Permission denied)

透過 Stackoverflow 查到這篇解答 nginx error connect to php5-fpm.sock failed (13: Permission denied),裡面提到兩種作法,其中一解法是直接修改 /var/run/php5-fpm.sock 為 666,讓其他使用者可以直接存取此檔案,但是此作法在下次重新開機後一樣會出現同問題,最終解法請修改 /etc/php-fpm.d/www.conf 如果是搭配 Nginx 請使用底下設定

user = nginx
group = nginx
; 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 0666
listen.owner = nginx
listen.group = nginx
listen.mode = 0666

PHP MVC Framework 搭配 Nginx + PHP-FPM 設定檔

Laravel PHP Framework
相信大家都知道 Nginx 搭配 PHP-FPM 用起來效能還不錯,這次來筆記如何設定 Nginx 去除 PHP MVC Framework 討厭的 index.php 字串,不管是 LaravelCodeIgniter 教學文件都是在 Apache 設定 .htaccess 來達成 Cleaner URL,Apache 最大好處支援 .htaccess,但是 Nginx 也有強大的效能,此篇紀錄如何設定 Nginx 達成 mod_rewrite 效果。 Continue reading “PHP MVC Framework 搭配 Nginx + PHP-FPM 設定檔”