Hardening PHP for rConfig
Hardening PHP for rConfig
Section titled “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.
Where the file is
Section titled “Where the file is”| 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.
Recommended php.ini settings
Section titled “Recommended php.ini settings”; Errors go to the log, never the page (php.display_errors)display_errors = Offdisplay_startup_errors = Offlog_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 = 1session.cookie_httponly = 1session.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 = 0PHP-FPM pool
Section titled “PHP-FPM pool”; /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 = apachelisten.owner = apachelisten.group = apachelisten.mode = 0660security.limit_extensions = .phpKeep PHP patched
Section titled “Keep PHP patched”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.