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/group and 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