PHP FPM - 检查是否正在运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/14915147/
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
PHP FPM - check if running
提问by Marty Wallace
The documentation on php fpm website says that php fpm is part for coe php as of 5.3.3
php fpm 网站上的文档说 php fpm 从 5.3.3 开始是 coe php 的一部分
I am running 5.3.10, how can i check that it is working correctly? I thought it was a service that ran on a port?
我正在运行 5.3.10,如何检查它是否正常工作?我以为这是在端口上运行的服务?
回答by SamGoody
Assuming you are on Linux, check if php-fpm is running by searching through the process list:
假设您使用的是 Linux,请通过搜索进程列表来检查 php-fpm 是否正在运行:
ps aux | grep php-fpm
If running over IP (as opposed to over Unix socket) then you can also check for the port:
如果通过 IP 运行(而不是通过 Unix 套接字),那么您还可以检查端口:
netstat -an | grep :9000
Or using nmap:
或者使用 nmap:
nmap localhost -p 9000
Lastly, I've read that you can request the status, but in my experience this has proven unreliable:
最后,我读到您可以请求状态,但根据我的经验,这已被证明是不可靠的:
/etc/init.d/php5-fpm status
回答by prosti
For php7.0-fpm I call:
对于 php7.0-fpm 我调用:
service php7.0-fpm status
php7.0-fpm start/running, process 25993
php7.0-fpm 启动/运行,进程 25993
Now watch for the good part. The process name is actually php-fpm7.0
现在注意好的部分。进程名其实是php-fpm7.0
echo `/bin/pidof php-fpm7.0`
26334 26297 26286 26285 26282
26334 26297 26286 26285 26282
回答by Jason
Here is how you can do it with a socket on php-fpm 7
这是在 php-fpm 7 上使用套接字的方法
install socat
apt-get install socat
#!/bin/sh
  if echo /dev/null | socat UNIX:/var/run/php/php7.0-fpm.sock - ; then
    echo "$home/run/php-fpm.sock connect OK"
  else
    echo "$home/run/php-fpm.sock connect ERROR"
  fi
You can also check if the service is running like this.
您还可以检查服务是否像这样运行。
service php7.0-fpm status | grep running
It will return
它会回来
Active: active (running) since Sun 2017-04-09 12:48:09 PDT; 48s ago
活动:自太平洋夏令时间 Sun 2017-04-09 12:48:09 起处于活动状态(正在运行);48 秒前
回答by bitkahuna
in case it helps someone, on amilinux, with php5.6 and php-fpm installed, it's:
如果它帮助某人,在 amilinux 上,安装了 php5.6 和 php-fpm,它是:
sudo /etc/init.d/php-fpm-5.6 status
sudo /etc/init.d/php-fpm-5.6 status
回答by Jared Kipe
PHP-FPM is a service that spawns new PHP processes when needed, usually through a fast-cgi module like nginx. You can tell (with a margin of error) by just checking the init.d script e.g. "sudo /etc/init.d/php-fpm status"
PHP-FPM 是一种在需要时生成新 PHP 进程的服务,通常通过像 nginx 这样的 fast-cgi 模块。您可以通过检查 init.d 脚本(例如“sudo /etc/init.d/php-fpm status”)来判断(有一定的误差)
What port or unix file socket is being used is up to the configuration, but often is just TCP port 9000. i.e. 127.0.0.1:9000
使用什么端口或unix文件套接字取决于配置,但通常只是TCP端口9000。即127.0.0.1:9000
The best way to tell if it is running correctly is to have nginx running, and setup a virtual host that will fast-cgi pass to PHP-FPM, and just check it with wget or a browser.
判断它是否正确运行的最好方法是让 nginx 运行,并设置一个虚拟主机,它将 fast-cgi 传递给 PHP-FPM,然后使用 wget 或浏览器检查它。

