简体   繁体   English

如何检查PHP-FPM是否正常运行?

[英]How to check if PHP-FPM is running properly?

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?我正在运行 5.3.10,如何检查它是否正常工作? I thought it was a service that ran on a port?我以为这是在端口上运行的服务?

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

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

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; 活动:自Sun 2017-04-09 12:48:09 PDT起活动(运行); 48s ago 48s前

如果它在amilinux上帮助某人,并安装了php5.6和php-fpm,它是:

sudo /etc/init.d/php-fpm-5.6 status

The bash script for the auto restart php-fpm:用于自动重启 php-fpm 的 bash 脚本:

#!/bin/bash
is_running=`service php7.4-fpm status | grep running`
if [[ ! $is_running ]]
then
    echo 'php7.4-fpm is running'
else
    echo 'php7.4-fpm is not running';
fi

Cron configuration for the checking every 5 minutes( /root/check_php7.4_status.sh - path to the bash script):每 5 分钟检查一次的 Cron 配置( /root/check_php7.4_status.sh - bash 脚本的路径):

*/5 * * * * /root/check_php7.4_status.sh 2>&1 >> '/root/check_php7.4_status.log'

PHP-FPM is a service that spawns new PHP processes when needed, usually through a fast-cgi module like nginx. PHP-FPM是一项服务,在需要时通常通过诸如nginx之类的fast-cgi模块生成新的PHP进程。 You can tell (with a margin of error) by just checking the init.d script eg "sudo /etc/init.d/php-fpm status" 您可以通过检查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. ie 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,并设置一个将快速cgi传递给PHP-FPM的虚拟主机,然后使用wget或浏览器对其进行检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM