Guide · Apache administrators
Apache + mod_php
Contents
1. Is mod_php in use?#
Read-only: changes nothing
# Debian/Ubuntu
apache2ctl -M 2>/dev/null | grep -i php
# RHEL-based
httpd -M 2>/dev/null | grep -i php
# MPM in use (mod_php usually requires prefork)
apachectl -V 2>/dev/null | grep -i mpm
If php_module or php7_module/php8_module appears, PHP is running inside the Apache processes.
2. Upgrade#
Through your distribution: Debian/Ubuntu (package libapache2-mod-phpX.Y) or RHEL-based (package php). On cPanel, see the cPanel guide.
3. Full Apache restart#
Restart: possible brief service interruption
sudo systemctl restart apache2 # Debian/Ubuntu
sudo systemctl restart httpd # RHEL-based
With mod_php, the PHP code is loaded inside the Apache processes. Prefer a full restart over a graceful one, so that no process is left running the old version, and confirm it with step 7.
4. Per-directory settings (.htaccess)#
According to the CVE-2026-109619 advisory, early diagnostic messages from invalid or deprecated settings applied before initialisation (such as php_value / php_flag in .htaccess with mod_php) can form part of the attack chain.
Read-only: changes nothing
# Find PHP settings in .htaccess
sudo grep -RnE '^\s*php_(value|flag|admin_value|admin_flag)' /var/www /home/*/public_html --include=.htaccess 2>/dev/null
Remove settings that no longer apply to your PHP version or that produce warnings in the logs.
5. Request limits (temporary exposure reduction)#
Changes packages or configuration: back up and test first
LimitRequestBody 8388608
LimitRequestFields 50
LimitRequestFieldSize 8190
php_admin_value session.upload_progress.enabled 0
See the impact of each setting in the temporary mitigations. After every change: apachectl configtest and a restart.
6. Consider moving to PHP-FPM#
mod_php requires the prefork MPM and runs PHP with Apache’s privileges. Moving to PHP-FPM (mod_proxy_fcgi) allows a separate user and pool per site. It is not a fix for PHP2Shell; FPM is affected too. It is, however, good isolation practice for the future.
7. Verification#
Read-only: changes nothing
for p in $(pgrep -f 'apache2|httpd'); do ls -l /proc/$p/exe 2>/dev/null; done | grep deleted
lsof -p "$(pgrep -o -f 'apache2|httpd')" 2>/dev/null | grep -E 'libphp|mod_php' | grep -i deleted
If the second command shows a deleted libphp*.so, Apache is still using the old library and needs a restart.
Main source: PHP project · php-src (GitHub) · php-src (GitHub)