安裝php7 的,如果php-fpm的這幾個參數設定不當了,會導致php-fpm啟動不了,nginx站點不能解析php文件,報404錯誤。
相關指令:
centos7 ,啟動php-fpm:
systemctl start php-fpm
查看php-fpm是否啟動:
ps -ef|grep php
php-fpm的核心參數配置,預設如下:
pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3
只針對動態方式dynamic說明如下:
max_children:動態方式下限定php-fpm的最大進程數
start_servers:動態方式下的起始php-fpm進程數量
min_spare_servers :動態方式空閒狀態下的最小php-fpm進程數量
max_spare_servers :動態方式空閒狀態下的最大php-fpm進程數量
這些參數如果注意改錯了參數會導致php-fpm啟動不了,nginx也就無法存取php文件,可查看日誌排查錯誤:
/usr/local/php/var/log/php-fpm.log
規則匯總:
1.max_children 必須大於min_spare_servers
2.max_children 必須大於max_spare_servers
3.start_servers 必須大於min_spare_servers
4.start_servers = min_spare_serversserver_servers
4.start_servers = min_spare_serversserver_spare_serversserver_spare_spare_sserver_spare_serversserver_spare_sserversserver_spare_sserver_spare_spare_serversserver_spare_serversserver_spare_sserver_spare_spare_serversserver_spare_sserver -spare_spare_serversserver_spare_serversserver_spare_sserver_spare_spare_sserver_spare_spare_server_spare_spare_sserver_spare_sserver_spare_spare_sserver_spare_spare_server_spare_spare_sserver_spare_sservers> ) / 2
###PS:我伺服器是8G內存,目前空閒還多,我就統一後面加了個0,分別是50、20、10、30。 ###以上是php7+的php-fpm參數配置(注意事項)的詳細內容。更多資訊請關注PHP中文網其他相關文章!