When trying to access PHP-FPM's status monitoring page, receiving a "File not found" error typically indicates configuration mismatches between your PHP-FPM setup and web server. Let's examine how to properly configure this essential monitoring feature.
First, check your existing PHP-FPM pool configuration for status paths:
# Check status and ping paths in PHP-FPM config
grep -ER "status|ping" /etc/php5/* | grep -v ":;"
# Expected output should show:
/etc/php5/fpm/pool.d/www.conf:pm.status_path = /status
/etc/php5/fpm/pool.d/www.conf:ping.path = /ping
/etc/php5/fpm/pool.d/www.conf:ping.response = pong
When testing directly via fcgi, we need proper environment variables:
# Correct way to test status page via fcgi
SCRIPT_NAME=/status \
SCRIPT_FILENAME=/status \
QUERY_STRING=full \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect /var/run/php-fpm-www.sock
# For ping test:
SCRIPT_NAME=/ping \
SCRIPT_FILENAME=/ping \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect /var/run/php-fpm-www.sock
For Nginx, you need proper location block configuration:
location ~ ^/(status|ping)$ {
access_log off;
allow 127.0.0.1;
deny all;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php-fpm-www.sock;
}
For Apache with mod_proxy_fcgi:
<Location /status>
SetHandler "proxy:unix:/var/run/php-fpm-www.sock|fcgi://localhost"
ProxySet enablereuse=on
</Location>
- Permission Issues: Ensure your web server user has access to the PHP-FPM socket file
- Path Mismatches: Verify pm.status_path matches exactly in both PHP-FPM and web server config
- PHP-FPM Restart Needed: Always restart PHP-FPM after configuration changes
- Output Format: Add ?json, ?html, or ?full to the status URL for different output formats
You can customize what information appears in the status page:
; In php-fpm pool configuration
pm.status_path = /status
; Available options: full, html, json
; Example URL: http://yourserver/status?json
Remember that the status page can reveal sensitive information about your server, so always restrict access to trusted IPs only.
When attempting to access PHP-FPM's status monitoring page, you're encountering a 404 error despite having the configuration properly set. This occurs both through browser requests and direct FastCGI connections.
# Current configuration verification
grep -ER "status|ping" /etc/php5/* | grep -v ":;"
/etc/php5/fpm/pool.d/www.conf:pm.status_path = /status
/etc/php5/fpm/pool.d/www.conf:ping.path = /ping
/etc/php5/fpm/pool.d/www.conf:ping.response = pong
The "Primary script unknown" error typically indicates one of these scenarios:
- Nginx/Apache isn't properly configured to handle the FastCGI pass
- PHP-FPM doesn't have permissions to access the status path
- Missing
allow
directive in PHP-FPM pool configuration - The socket connection isn't properly established
For Nginx servers, you'll need this location block:
location ~ ^/(status|ping)$ {
access_log off;
allow 127.0.0.1;
deny all;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php-fpm-www.sock;
}
For PHP-FPM pool configuration (/etc/php5/fpm/pool.d/www.conf):
pm.status_path = /status
ping.path = /ping
ping.response = pong
; Restrict access
listen.allowed_clients = 127.0.0.1
To test the FastCGI interface directly (bypassing web server):
# For status page
SCRIPT_NAME=/status SCRIPT_FILENAME=/status REQUEST_METHOD=GET \
cgi-fcgi -bind -connect /var/run/php-fpm-www.sock
# For ping endpoint
SCRIPT_NAME=/ping SCRIPT_FILENAME=/ping REQUEST_METHOD=GET \
cgi-fcgi -bind -connect /var/run/php-fpm-www.sock
On RedHat-based systems with SELinux:
# Check SELinux context
ls -Z /var/run/php-fpm-www.sock
# Temporary allow HTTPD to connect
setsebool -P httpd_can_network_connect 1
If you still can't access via web server, try these alternatives:
# Using curl through localhost
curl "http://localhost/status?json"
# Using socat for raw socket communication
echo -e "GET /status HTTP/1.0\r\n\r\n" | socat unix-connect:/var/run/php-fpm-www.sock -