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
,這個世界終於清凈了!