简体   繁体   English

在Bitnami LAMP堆栈中设置并访问PHP-FPM状态页面

[英]Set up and access the PHP-FPM status page in Bitnami LAMP stack

I'd like to see the PHP-FPM status page on a Bitnami LAMP stack system. 我想在Bitnami LAMP堆栈系统上看到PHP-FPM状态页面。

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? 那么我需要做些什么来让它工作?

There are two parts to this answer. 这个答案分为两部分。

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配置中启用状态页面处理程序,然后您需要设置Apache以将给定的URL路由到该处理程序。

To set up PHP-FPM: 要设置PHP-FPM:

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

(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.) (或者使用你最喜欢的编辑器的任何命令。另外,如果你已经将bitnami安装为当前用户而不是使用Bitnami AMI,那么你可能不需要sudo,这使得该文件具有root权限。)

In the file, find the line 在文件中,找到该行

;pm.status_path = /status    

And change it to: 并将其更改为:

pm.status_path = /php_fpm_status

Save the file. 保存文件。 (In nano, CTRL-X , then Y to confirm) (在nano, CTRL-X ,然后Y确认)

Then set up a handler in Apache: 然后在Apache中设置一个处理程序:

Find the Apache config for the domain that you want to serve the status page. 找到要为状态页面提供服务的域的Apache配置。 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. 默认情况下,我认为该文件类似于/path/to/bitnami/apache2/conf/bitnami/bitnami.conf但如果你有一个带有vhosts的实时服务器,你可能已经改变了它。

In the config you need to add: 在配置中,您需要添加:

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

Restart things: 重启东西:

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

Then open your new location in a web browser or curl it: 然后在Web浏览器中打开您的新位置或将其卷曲:

curl ip.add.re.ss/php_fpm_status

And you should see the PHP-FPM status, something like: 你应该看到PHP-FPM状态,例如:

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

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. 到目前为止一切都很好,但任何人和他的恶意猴子现在都可以查看你的FPM状态,所以让我们用IP地址锁定它。

You can use any IP (eg your personal IP) by following the format below. 您可以按照以下格式使用任何IP(例如您的个人IP)。 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). 在Amazon EC2上,我们还可以将请求限制为仅来自服务器自己的私有IP地址(不是公开可见的EIP)。 So if the private IP is 10.0.0.1: 因此,如果私有IP是10.0.0.1:

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

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. 重新启动Apache,你仍然可以使用curl 10.0.0.1/php_fpm_status通过命令行访问状态,但是对URL的任何远程请求都会给出403 Forbidden响应。

(You can also password protect the page or do other fancy things, but IP lockdown is enough for this basic example) (您也可以使用密码保护页面或做其他奇特的事情,但IP锁定就足够了这个基本示例)

Enjoy! 请享用! And if there is a better way to do any of this then please share the wisdom :-) 如果有更好的方法可以做到这一点,那么请分享智慧:-)

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

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