未加星标

Getting The PHP-FPM Status From The Command Line

字体大小 | |
[开发(php) 所属分类 开发(php) | 发布者 店小二05 | 时间 2018 | 作者 红领巾 ] 0人收藏点击收藏

Today, I posted the following into my company’s HipChat…

[3:41 PM] Me:

$ curl 127.0.0.1:9000/status

curl: (56) Failure when receiving data from the peer

Is this supposed to work?

I quickly learned that no, it is not supposed to work…

[3:41 PM] Coworker:

no it doesn’t use http

Here I’ll go into details on how you can get thephp-FPM status from the command line.

The cgi-fcgi executable

In order to communicate with a FastCGI application (like PHP-FPM) you can use the cgi-fcgi executable. It does not come installed by default on most OSes.

Per the article “Directly connecting to PHP-FPM” from www.thatsgeeky.com you can yum install it as follows…

yum --enablerepo=epel install fcgi

I personally tested the yum install out on a CentOS machine and it worked fine.

If you’re using apt , according to easyengine.io’s similarly titled blog post “Directly connect to PHP-FPM” it is available as follows…

apt-get install libfcgi0ldbl

Once installed you’ll be able to use the cgi-fcgi binary to talk directly to PHP-FPM.

Ensuring That The Status Page Is Available

By default, PHP-FPM does not make the status page available. You’ll need to ensure that the following is included in your PHP-FPM configuration…

NOTE: You don’t need to use /status for the path and can use another path if you’d prefer

pm.status_path = /status Communicating With PHP-FPM

At this point you’ll be able to use cgi-fcgi to send requests directly to PHP-FPM. However it’s important to confirm whether or not PHP-FPM is listening on a port or a unix socket.

If listening on a port you’ll see something like this in your PHP-FPM configuration…

listen = 127.0.0.1:9000

On a Unix socket you’ll see this…

listen = /var/run/php-fpm/www.sock

If PHP-FPM is listening on a port you can send requests to it with cgi-fcgi as follows…

SCRIPT_NAME=/status \ SCRIPT_FILENAME=/status \ REQUEST_METHOD=GET \ cgi-fcgi -bind -connect 127.0.0.1:900

If it’s listening on a socket simply update the connection name to point to the Unix socket.

SCRIPT_NAME=/status \ SCRIPT_FILENAME=/status \ REQUEST_METHOD=GET \ cgi-fcgi -bind -connect /var/run/php-fpm/www.sock

When connecting to a Unix socket, you need to ensure the user you’re running the command as has permissions to read the socket file.


Getting The PHP-FPM Status From The Command Line

Hi, I'm Max!

I'm a software developer who mainly works inPHP, but also dabbles inRuby andGo. Technical topics that interest me aremonitoring,security andperformance.

During the day I solve challenging technical problems at Something Digital where I mainly work with theMagento platform. I alsoblog about tech, work on open source and hunt for bugs .

If you'd like to get in touch with me the best way is on Twitter .

本文开发(php)相关术语:php代码审计工具 php开发工程师 移动开发者大会 移动互联网开发 web开发工程师 软件开发流程 软件开发工程师

代码区博客精选文章
分页:12
转载请注明
本文标题:Getting The PHP-FPM Status From The Command Line
本站链接:https://www.codesec.net/view/610793.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 开发(php) | 评论(0) | 阅读(96)