无法在 Ubuntu 上启动或停止 php-fpm
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23464157/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't start or stop php-fpm on Ubuntu
提问by CodeSmith
I'm trying to install php-fpm for the first time on Ubunutu. I have installed it via
我第一次尝试在 Ubunutu 上安装 php-fpm。我已经通过安装它
sudo apt-get install php5-fpm
When the install finishes, I run ps -waux | grep php5
to see if anything is running. I get the following:
安装完成后,我运行ps -waux | grep php5
以查看是否有任何东西在运行。我得到以下信息:
root 9625 0.5 0.6 133612 12836 ? Ss 22:49 0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
It looks like it is running, so I tried to stop it by executing:
看起来它正在运行,所以我试图通过执行来停止它:
sudo /etc/init.d/php5-fpm stop
This appears to do nothing. No error message is given on the command line and when I run ps
again, the same process exists. I am able to get it to stop if I run:
这似乎没有任何作用。命令行上没有给出错误消息,当我ps
再次运行时,存在相同的过程。如果我运行,我可以让它停止:
sudo service php5-fpm stop
The first time I ran this command I got an error about not being able to find a directory, but the process did stop. When I start and stop the service again, it seems to work fine and I don't get an error message about a missing directory.
我第一次运行这个命令时,我收到一个关于无法找到目录的错误,但该过程确实停止了。当我再次启动和停止服务时,它似乎工作正常,而且我没有收到有关缺少目录的错误消息。
Can someone explain to me why the /etc/init.d/php5-fpm method does not work? All of the tutorials I've seen use this method to start and stop php5-fpm.
有人可以向我解释为什么 /etc/init.d/php5-fpm 方法不起作用吗?我看过的所有教程都使用这种方法来启动和停止 php5-fpm。
回答by user3647449
Quick answer...you don't use the init.d scripts to control (stop / start /status etc) of php-fpm because it's controlled by the newer 'upstart'. Use the following service command to stop and restart etc. I think it's a bit of a 'bug' that it quietly exits without stating that it's now controlled by upstart.
快速回答...您不使用 init.d 脚本来控制(停止/启动/状态等)php-fpm,因为它由较新的“新贵”控制。使用以下服务命令来停止和重新启动等。我认为这是一个“错误”,它悄悄退出而没有说明它现在由 upstart 控制。
More detailed look at this problem, that leads to above explanation.
更详细地看这个问题,导致上面的解释。
I see exactly the same problem on Ubuntu 14.04, you can stop / start / get status of php5-fpm using the service commands: I.E these work fine :-
我在 Ubuntu 14.04 上看到完全相同的问题,您可以使用服务命令停止/启动/获取 php5-fpm 的状态:IE 这些工作正常:-
# sudo service php5-fpm status
php5-fpm start/running, process 18793
# sudo service php5-fpm stop
php5-fpm stop/waiting
# sudo service php5-fpm status
php5-fpm stop/waiting
# sudo service php5-fpm start
php5-fpm start/running, process 18949
# sudo service php5-fpm status
php5-fpm start/running, process 18949
BUT the /etc/init.d/php5-fpm command has no effect :-
但是 /etc/init.d/php5-fpm 命令没有效果:-
# /etc/init.d/php5-fpm stop
# ps -ef | grep php
root 18949 1 0 12:15 ? 00:00:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
www-data 18952 18949 0 12:15 ? 00:00:00 php-fpm: pool www
www-data 18953 18949 0 12:15 ? 00:00:00 php-fpm: pool www
root 18970 10051 0 12:17 pts/2 00:00:00 grep --color=auto php
Note nothing is returned, and the process is not stopped. Similarly for status and start versions, nothing is returned and the process is unaffected.
请注意,不会返回任何内容,并且该过程不会停止。同样,对于状态和开始版本,不返回任何内容并且过程不受影响。
I found the line that it exits the init.d script on.... init_is_upstart
:
我发现它在...上退出 init.d 脚本的那一行init_is_upstart
:
# Don't run if we are running upstart
if init_is_upstart; then
exit 1
fi
Surely it should state an error message here...like 'Use service commands to stop/start php-fpm'.
当然,它应该在此处说明错误消息……例如“使用服务命令停止/启动 php-fpm”。
回答by st0ma
I had similar problem that relates to php5-fpm on Ubuntu 14.10. I have configured php5-fpm for one of the virtual hosts and when trying to browse the site i got the 503 Service Unavailable. Every time I tried
我在 Ubuntu 14.10 上遇到了与 php5-fpm 相关的类似问题。我已经为其中一个虚拟主机配置了 php5-fpm,当我尝试浏览该站点时,我收到 503 服务不可用。每次我尝试
root@testupgrade:~# service php5-fpm restart
stop: Unknown instance:
php5-fpm start/running, process 2775
I got in the syslog the following:
我在系统日志中得到以下内容:
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
What I tried then is to check if my php5-fpm configuration for this virtual host pool is actually working. It was configured to listed on a TCP port with the following configuration in /etc/php5/fpm/pool.d/www.conf I have correctly instructed the pool to listed as follows:
我当时尝试的是检查这个虚拟主机池的 php5-fpm 配置是否真的有效。它被配置为在 /etc/php5/fpm/pool.d/www.conf 中使用以下配置在 TCP 端口上列出我已正确指示池列出如下:
listen = 127.0.0.1:9000
I tried restarting few more times with the service command and since it did not work I decided checking the startup scripts. I edited the /etc/init/php5-fpm.conf and I noticed that I already have the latest bug-fixed version of the line "reload signal USR2". Then I noticed the following line:
我尝试使用 service 命令重新启动几次,由于它不起作用,我决定检查启动脚本。我编辑了 /etc/init/php5-fpm.conf 并注意到我已经有了“重新加载信号 USR2”行的最新错误修复版本。然后我注意到以下行:
pre-start exec /usr/lib/php5/php5-fpm-checkconf
I checked the /usr/lib/php5/php5-fpm-checkconf script and noticed the syntax check that is appended to the $errors variable:
我检查了 /usr/lib/php5/php5-fpm-checkconf 脚本并注意到附加到 $errors 变量的语法检查:
/usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/php-fpm.conf
I executed it in the shell and noticed the following:
我在 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
This means that I have touched my php-fpm.conf and messed it up however the error was nowhere to be found and I had no indication that this is the reason for the php5-fpm service to fail starting. I fixed the syntax in the /etc/php5/fpm/pool.d/www.conf file and then tried restarting again with the service command. The service started and opened a tcp listener on the required port 9000. The vhost also started working. So always check the php-fpm syntax and configuration with the above command to avoid issues with the service not starting.
这意味着我已经触及了我的 php-fpm.conf 并将其搞砸了,但是找不到错误,而且我没有迹象表明这是 php5-fpm 服务启动失败的原因。我修复了 /etc/php5/fpm/pool.d/www.conf 文件中的语法,然后尝试使用 service 命令再次重新启动。该服务启动并在所需端口 9000 上打开了一个 tcp 侦听器。 vhost 也开始工作。因此,请始终使用上述命令检查 php-fpm 语法和配置,以避免服务无法启动的问题。
回答by Diemuzi
Typically an init script will not always spit out the problem causing the situation to happen. Your best option is to cat /etc/init.d/php5-fpm
and find the command it is trying to run and then use that command to start the process manually.
通常,init 脚本不会总是吐出导致这种情况发生的问题。您最好的选择是cat /etc/init.d/php5-fpm
找到它尝试运行的命令,然后使用该命令手动启动该过程。
Speaking from experience with FPM start-up scripts, FPM will normally spit out the error you cannot see or are missing from random log files and then you'll be able to find and fix that error. Once resolved, your init script should be good to go afterwards.
根据 FPM 启动脚本的经验,FPM 通常会吐出您看不到或从随机日志文件中丢失的错误,然后您将能够找到并修复该错误。解决后,您的 init 脚本应该可以在之后继续使用。