设置并访问Bitnami LAMP堆栈中的PHP-FPM状态页面 [英] Set up and access the PHP-FPM status page in Bitnami LAMP stack

查看:143
本文介绍了设置并访问Bitnami LAMP堆栈中的PHP-FPM状态页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Bitnami LAMP堆栈系统上查看PHP-FPM状态页面.

I'd like to see the PHP-FPM status page on a Bitnami LAMP stack system.

但是,当我尝试时,我得到一个空白页,或者一个错误消息:

However, when I try I get a blank page, or an error saying:

Request exceeded the limit of 10 internal redirects due to probable configuration error.

那我该怎么做才能使其正常工作?

So what do I need to do to get it working?

推荐答案

此答案分为两部分.

首先,您需要在PHP-FPM配置中启用状态页面处理程序,然后需要设置Apache以将给定的URL路由到该处理程序.

The first is that you need to enable the status page handler in the PHP-FPM configuration and then you need to set up Apache to route a given URL through to that handler.

设置PHP-FPM:

cd /path/to/bitnami
cd php/etc
sudo nano php-fpm.conf

(或使用您喜欢的编辑器的任何命令.此外,如果您已将bitnami作为当前用户安装,而不是使用使该文件具有根所有权的Bitnami AMI,则可能不需要sudo.)

(Or whatever command to use your favourite editor. Also, you might not need sudo if you've installed bitnami as the current user instead of using a Bitnami AMI which leaves this file with root ownership.)

在文件中找到行

;pm.status_path = /status    

并将其更改为:

pm.status_path = /php_fpm_status

保存文件. (在nano中,先按CTRL-X,然后按Y进行确认)

Save the file. (In nano, CTRL-X, then Y to confirm)

然后在Apache中设置处理程序:

找到要为状态页提供服务的域的Apache配置.默认情况下,我认为该文件类似于/path/to/bitnami/apache2/conf/bitnami/bitnami.conf,但是如果您具有带有虚拟主机的实时服务器,则可能已对其进行了更改.

Find the Apache config for the domain that you want to serve the status page. By default I think that file is something like /path/to/bitnami/apache2/conf/bitnami/bitnami.conf but you've probably changed it if you have a live server with vhosts.

在配置中,您需要添加:

In the config you need to add:

<VirtualHost xxx>
  ...
  <LocationMatch "/php_fpm_status">
    SetHandler "proxy:fcgi://www-fpm"
  </LocationMatch>
  ...
</VirtualHost>

重新开始:

sudo /path/to/bitnami/ctlscript.sh restart

然后在网络浏览器中打开您的新位置或对其进行卷曲:

Then open your new location in a web browser or curl it:

curl ip.add.re.ss/php_fpm_status

您应该看到PHP-FPM状态,例如:

And you should see the PHP-FPM status, something like:

pool:                 www
process manager:      ondemand
start time:           21/May/2016:20:28:57 +0000
start since:          13
accepted conn:        1
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       0
active processes:     1
total processes:      1
max active processes: 1
max children reached: 0
slow requests:        0

到目前为止,一切都很好,但是现在任何人和他的恶意猴子都可以查看您的FPM状态,因此请按IP地址将其锁定.

So far so good, but any man and his malicious monkey can now view your FPM status, so lets lock it down by IP address.

您可以按照以下格式使用任何IP(例如您的个人IP).在Amazon EC2上,我们还可以将请求限制为仅来自服务器自己的私有IP地址的请求(而不是公开可见的EIP).因此,如果私有IP为10.0.0.1:

You can use any IP (e.g. your personal IP) by following the format below. On Amazon EC2 we can also restrict the request to only ones originating from the server's own private IP address (not the publicly visible EIP). So if the private IP is 10.0.0.1:

<VirtualHost xxx>
  ...
  <LocationMatch "/php_fpm_status">
    Require ip 10.0.0.1
    SetHandler "proxy:fcgi://www-fpm"
  </LocationMatch>
  ...
</VirtualHost>

重新启动Apache,您仍然应该可以使用curl 10.0.0.1/php_fpm_status通过命令行访问状态,但是对URL的任何远程请求都将给出403 Forbidden响应.

Restart Apache and you should still be able to access the status via the command line using curl 10.0.0.1/php_fpm_status but any remote request to the URL will give a 403 Forbidden response.

(您还可以用密码保护页面或执行其他一些奇特的事情,但是对于此基本示例而言,IP锁定就足够了)

(You can also password protect the page or do other fancy things, but IP lockdown is enough for this basic example)

享受!如果有更好的方法可以做到这一点,请分享智慧:-)

Enjoy! And if there is a better way to do any of this then please share the wisdom :-)

这篇关于设置并访问Bitnami LAMP堆栈中的PHP-FPM状态页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆