Here is how you can enable PHP-FPM Status Page for Nginx using Ubuntu as OS on Rackspace Cloud Server. It can throw error with improper setup. Indeed, this status page is quite important but has some security vulnerabilities as it might be checked by the Public using simple GET
request. Hence, we suggest the readers to follow the method on dev setup first.
PHP-FPM Status Page for Nginx on Ubuntu, Rackspace Cloud Server
We assume that you are using a multi-server setup with PVHVM servers with at least 2 virtual cores. As a rule of thumb, you should not use this server as both forward proxy and reverse proxy. You should follow the guides like using a separate database / application server to have a scalable, redundant system first. You might need to manually compile Nginx with HttpStubStatusModule
if it is not latest Ubuntu or sources.list
is custom set, else you might not have the function ready to be enabled.
PHP-FPM Status Page for Nginx on Ubuntu, Rackspace Cloud Server : Steps
The sample config page should be located at :
---
1 2 3 4 | http://example.com/status # or http://example.com/status.html # see http://nginx.com/products/live-activity-monitoring/ |
If you request /status (or whichever URI matches the location group), then NGINX Plus will respond with a JSON document containing the current activity data.
Run this command to check :
1 | nginx -V | grep --color -o http_stub_status |
There will be output like :
1 2 3 4 | nginx version: nginx/1.4.6 (Ubuntu) built by gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1) TLS SNI support enabled configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module |
Open /etc/php5/fpm/pool.d/www.conf
to edit :
1 2 3 4 5 6 | nano /etc/php5/fpm/pool.d/www.conf # this # ;pm.status_path = /status # change to # pm.status_path = /status # write out (^ + O) and exit (^ + X); SHIFT + 6 = ^ on Mac keyboard |
Search pm.status_path
after evoking the search function in Nano with ^ + W
. Normally, it is commented. Next, pm.status_path = /status
path can be changed and commented out. Next you should edit nginx.conf
file (usually located at etc/nginx/nginx.conf
, if you can not find use locate nginx.conf
command) and do these changes :
1 2 3 4 5 6 7 8 9 10 11 12 | location ~ ^/(status|ping)$ { access_log off; allow 127.0.0.1; allow A.B.C.D #Public IP is A.B.C.D; deny all; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; # enable the lines below one by one by uncommenting only # if you are not getting the thing rightly #error_page 404 /error/404.php; #fastcgi_pass unix:/tmp/php5-fpm.sock; } |
Check config after saving the file :
1 | nginx -t |
Then do these :
1 2 3 | service php5-fpm restart service nginx restart # do not combine with && |
You’ll get the status here :
1 | http://A.B.C.D./status?full |
You might face error, due to upstream block or not having libfcgi0ldbl
component. We advice to comment out Public IP and curl from shell. If you activate private IP of another server or loadbalancer, you can avoid the public access.