Article
Apache mod_php to PHP-FPM Modernization
Move legacy Apache mod_php hosts to php-fpm via proxy_fcgi with clear process isolation, sockets, permissions, and rollback.
Classic LAMP stacks embedded PHP as mod_php inside Apache. PHP-FPM separates the web server from PHP workers: Apache proxies FastCGI requests to a pool running as a dedicated user. That model improves isolation, enables multiple PHP versions per host, and matches how most current panels deploy PHP.
LEGACY — mod_php sketch
LoadModule php7_module modules/libphp7.so
SetHandler application/x-httpd-php
MODERN — proxy_fcgi to FPM
# Enable proxy_fcgi; socket path must match the pool
SetHandler "proxy:unix:/run/php-fpm/app.sock|fcgi://localhost/"
Cutover checklist
- Install and configure a pool with correct
user/groupand listen socket mode - Point the VirtualHost document root at
public/if you have separated it - Disable mod_php for that vhost to avoid double handlers
- Reload Apache and FPM; watch error logs for socket permission failures
- Keep the previous vhost fragment for quick rollback
Official Apache docs: httpd.apache.org. Pool sizing: PHP-FPM Pool Calculator. Ini: php.ini Generator.
Related reading
- Composer Modernization Center Add Composer to legacy PHP projects, migrate includes to autoloading, set platform constraints, and replace a…
- PHP 5 to Modern PHP: Complete Incremental Migration Guide A deep, production-minded path from PHP 5.x codebases to supported PHP 8.x: removed extensions, charset, PDO,…
- PHP Security Modernization for Legacy Applications Upgrade inherited PHP security practices: prepared statements, password hashing, sessions, CSRF, XSS escaping…
- PHP 7 to PHP 8 Migration Guide Deep guide to PHP 8.0 breaking changes that matter for PHP 7 applications, with upgrade tactics through suppo…
- Inheriting a Legacy PHP Application A first-30-days playbook for developers handed an unfamiliar PHP codebase: runtime truth, risk triage, and sa…