我在 Ubuntu 14.10 上遇到了与 php5-fpm 相关的类似问题。
我已经为其中一个虚拟主机配置了 php5-fpm,当尝试浏览该站点时,我得到了 503 Service Unavailable。
每次都试了
root@testupgrade:~# service php5-fpm restart
stop: Unknown instance:
php5-fpm start/running, process 2775
我在系统日志中得到了以下信息:
Dec 7 14:08:53 testupgrade kernel: [ 230.711612] init: php5-fpm main process (2775) terminated with status 78
Dec 7 14:08:53 testupgrade kernel: [ 230.711639] init: php5-fpm main process ended, respawning
Dec 7 14:08:53 testupgrade kernel: [ 230.866617] init: php5-fpm main process (2783) terminated with status 78
Dec 7 14:08:53 testupgrade kernel: [ 230.866643] init: php5-fpm main process ended, respawning
Dec 7 14:08:54 testupgrade kernel: [ 231.027522] init: php5-fpm main process (2791) terminated with status 78
Dec 7 14:08:54 testupgrade kernel: [ 231.027548] init: php5-fpm main process ended, respawning
Dec 7 14:08:54 testupgrade kernel: [ 231.137792] init: php5-fpm main process (2799) terminated with status 78
Dec 7 14:08:54 testupgrade kernel: [ 231.137807] init: php5-fpm main process ended, respawning
Dec 7 14:08:54 testupgrade kernel: [ 231.221146] init: php5-fpm main process (2807) terminated with status 78
Dec 7 14:08:54 testupgrade kernel: [ 231.221161] init: php5-fpm main process ended, respawning
Dec 7 14:08:54 testupgrade kernel: [ 231.301859] init: php5-fpm main process (2815) terminated with status 78
Dec 7 14:08:54 testupgrade kernel: [ 231.301874] init: php5-fpm main process ended, respawning
Dec 7 14:08:54 testupgrade kernel: [ 231.381635] init: php5-fpm main process (2823) terminated with status 78
Dec 7 14:08:54 testupgrade kernel: [ 231.381649] init: php5-fpm main process ended, respawning
Dec 7 14:08:54 testupgrade kernel: [ 231.469211] init: php5-fpm main process (2831) terminated with status 78
Dec 7 14:08:54 testupgrade kernel: [ 231.469225] init: php5-fpm main process ended, respawning
Dec 7 14:08:54 testupgrade kernel: [ 231.548950] init: php5-fpm main process (2839) terminated with status 78
Dec 7 14:08:54 testupgrade kernel: [ 231.548964] init: php5-fpm main process ended, respawning
Dec 7 14:08:54 testupgrade kernel: [ 231.628781] init: php5-fpm main process (2847) terminated with status 78
Dec 7 14:08:54 testupgrade kernel: [ 231.628795] init: php5-fpm main process ended, respawning
Dec 7 14:08:54 testupgrade kernel: [ 231.711933] init: php5-fpm main process (2855) terminated with status 78
Dec 7 14:08:54 testupgrade kernel: [ 231.711947] init: php5-fpm respawning too fast, stopped
然后我尝试检查这个虚拟主机池的 php5-fpm 配置是否真的有效。
它被配置为在 /etc/php5/fpm/pool.d/www.conf 中具有以下配置的 TCP 端口上列出
我已正确指示池列出如下:
listen = 127.0.0.1:9000
我尝试使用 service 命令重新启动几次,但由于它不起作用,我决定检查启动脚本。
我编辑了 /etc/init/php5-fpm.conf,我注意到我已经有了最新的错误修复版本的“重新加载信号 USR2”行。
然后我注意到以下行:
pre-start exec /usr/lib/php5/php5-fpm-checkconf
我检查了 /usr/lib/php5/php5-fpm-checkconf 脚本并注意到附加到 $errors 变量的语法检查:
/usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/php-fpm.conf
我在 shell 中执行它并注意到以下内容:
root@testupgrade:~# /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/php-fpm.conf
[07-Dec-2014 13:46:14] ERROR: [pool www] 'slowlog' must be specified for use with 'request_slowlog_timeout'
[07-Dec-2014 13:46:14] ERROR: failed to post process the configuration
[07-Dec-2014 13:46:14] ERROR: FPM initialization failed
这意味着我已经触摸了我的 php-fpm.conf 并将其搞砸了,但是找不到错误,并且我没有迹象表明这是 php5-fpm 服务无法启动的原因。
我修复了 /etc/php5/fpm/pool.d/www.conf 文件中的语法,然后尝试使用 service 命令再次重新启动。
该服务启动并在所需端口 9000 上打开了一个 tcp 侦听器。
虚拟主机也开始工作。
因此,请务必使用上述命令检查 php-fpm 语法和配置,以避免出现服务无法启动的问题。