PHP 7: Maintaining and Upgrading Legacy Apps · Operating Legacy PHP in Production
Monitoring Legacy PHP Applications
Know when the app is unhealthy with logs, metrics and uptime checks.
Minimum monitoring for any production PHP app: an uptime/synthetic check on key pages, PHP-FPM status metrics (active processes, listen queue, max children reached), error-rate alerts from logs or an error tracker, database slow query monitoring, and server resources. APM tools (New Relic, Datadog, Elastic APM, OpenTelemetry PHP) add traces with little code change.
# Nginx: expose FPM status internally for the metrics exporter
location ~ ^/(fpm-status|fpm-ping)$ {
allow 127.0.0.1;
deny all;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
}
Common pitfalls
- Alerting on every error log line (alert fatigue).
- Public FPM status endpoints.
- No alert when 'max children reached' indicates saturation.
Key points
- Uptime checks + error-rate alerts
- Watch FPM saturation
- APM for traces
Further reading: PHP manual: FPM status page
Practice questions
What does 'max children reached' in PHP-FPM status mean?
Answer
All workers were busy and requests queued; it's a saturation signal pointing to slow requests or too few workers for the load.
Which alert is most valuable for a legacy app with little monitoring?
Answer
An alert on user-facing symptoms: failing synthetic checks or a spike in 5xx/error rate, rather than on individual log lines.
Open in the app to mark lessons complete, take notes and track your progress.