Mac 配置 php-fpm 時出現'/private/etc/php-fpm.conf': No such file or directory (2)

https://github.com/musicode/test/issues/5php

 

Mac 自帶 php-fpm,在終端執行 php-fpm,會報以下錯誤:git

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,而後再根據須要改動配置。github

cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf

執行 php-fpm,再次報錯:socket

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

修改 php-fpm.conf error_log 配置爲 /usr/local/var/log/php-fpm.log,並把 user 和 group 改成和當前用戶同樣。post

執行 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,再次報錯:code

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:9999get

執行 php-fpm -t,這個世界終於清淨了!it

相關文章
相關標籤/搜索