Skip to content

Hardening PHP for rConfig

Most PHP hardening is a handful of php.ini lines. From V8.5.0, Security Review checks each of them as the web server’s PHP sees them, which matters because the command line often loads a different php.ini from PHP-FPM.

OS Web PHP (PHP-FPM) Pools
RHEL, Rocky, AlmaLinux /etc/php.ini and /etc/php.d/*.ini /etc/php-fpm.d/*.conf
Ubuntu, Debian /etc/php/8.4/fpm/php.ini /etc/php/8.4/fpm/pool.d/*.conf

Restart PHP-FPM after any change: sudo systemctl restart php-fpm (RHEL) or sudo systemctl restart php8.4-fpm (Ubuntu). Restart Horizon too if you changed the CLI php.ini.

; Errors go to the log, never the page (php.display_errors)
display_errors = Off
display_startup_errors = Off
log_errors = On
; Keep function arguments (passwords) out of stack traces (php.exception_args)
zend.exception_ignore_args = On
; Do not announce the PHP version (php.expose)
expose_php = Off
; Never include code from a URL (php.url_include)
allow_url_include = Off
; Native PHP sessions (php.session)
session.use_strict_mode = 1
session.cookie_httponly = 1
session.use_only_cookies = 1
; Not used by rConfig; part of the rCFG-SA-2026-01 mitigation (php.upload_progress)
session.upload_progress.enabled = 0
; Production assertion mode (php.assertions)
zend.assertions = -1
; PHP-FPM only (php.cgi_fix_pathinfo)
cgi.fix_pathinfo = 0
; /etc/php-fpm.d/www.conf (RHEL) or /etc/php/8.4/fpm/pool.d/www.conf (Ubuntu) (php.fpm_pool)
user = apache ; www-data on Ubuntu. Never root.
group = apache
listen.owner = apache
listen.group = apache
listen.mode = 0660
security.limit_extensions = .php

php.version_min fails when PHP is below rConfig’s minimum (8.4.28 for 8.5) and a PHP advisory applies, and php.version_eol warns six months before a PHP branch stops getting security fixes. Update PHP through the OS packages; see Update PHP.

Standards: CIS Benchmarks (PHP and web server sections), NIST SP 800-53 CM-6, CM-7, SI-2, SI-11, OWASP ASVS V14.