https://github.com/musicode/test/issues/5
Mac 自帶 php-fpm,在終端執行
php-fpm
,會報如下錯誤: ERROR: failed to open configuration file '/private/etc/php-fpm.conf': No such file or directory (2)
ERROR: failed to load configuration file '/private/etc/php-fpm.conf'
ERROR: FPM initialization failed
錯誤資訊顯示,不能打開配置檔案,
cd /private/etc
,發現沒有 php-fpm.conf 檔案,但是有 php-fpm.conf.default 檔案。這個檔案是預設配置,我們可以複制一份,改名為 php-fpm.conf,然後再根據需要改動配置。
cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf
執行
php-fpm
,再次報錯:
ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory (2)
ERROR: failed to post process the configuration
ERROR: FPM initialization failed
錯誤資訊顯示,不能打開錯誤日志檔案。
cd /usr/var/log
發現根本沒有這個目錄,甚至連 var 目錄都沒有,加上為了避免權限問題,幹脆配置到 /usr/local/var/log 目錄。
修改 php-fpm.conf
error_log
配置為
/usr/local/var/log/php-fpm.log
,并把
user
和
group
改為和目前使用者一樣。
php-fpm
NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
于是
sudo php-fpm
ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (48)
ERROR: FPM initialization failed
編輯 php-fpm.conf,修改
listen
為
127.0.0.1:9999
。
php-fpm -t
,這個世界終于清淨了!