The cPanel PHPRC PHP Patch for EasyApache 4
Last modified: 2024 August 23
Overview
We created a PHP patch that forces an EasyApache 4 system to read its php.ini files in the same order as an EasyApache 3 system.
Patch behavior
Your system’s PHP handler determines how your system behaves with this patch and which global values the system uses.
If you use the CGI or DSO PHP handler, the system uses the global values that the /opt/cpanel/ea-php##/root/etc/php.ini or the /opt/cpanel/ea-php##/root/etc/php.d/*.ini files define.
If your system uses the suPHP PHP handler, the system loads PHP INI directives in a specific order.
Your PHP handler determines your system’s behavior.
The system no longer uses local.ini files. If a local.ini file exists on your system, run the following command to migrate your file to the system’s primary php.ini file:
/usr/local/cpanel/scripts/migrate_local_ini_to_php_ini --run
CGI or DSO
The system only uses the values that the /opt/cpanel/ea-php##/root/etc/php.ini file or the .ini file in the /opt/cpanel/ea-php##/root/etc/php.d/ directory specifies.
SuPHP
The system loads PHP INI directives in the following order. The system uses the first instance of a directive that it finds.
- We strongly recommend that you allow your system to load the
.inifiles and directives as it finds them. This guarantees the most predictable results. - We strongly recommend that you do not specify a location for your
.inifile with the[phprc_paths]section of thesuphp.conffile, thesuPHP_ConfigPathdirective, or set the PHPRC environmental variable. Unexpected behavior may occur.
- The
.user.inifile that exists in the same directory as the PHP script.Important:- Do not set the
user_ini.filenamedirective. - If the system does not find a
.user.inifile, it searches up the directory tree until it finds one and uses that file as if it existed in the PHP file’s directory. In PHP 7 and later, the system will search below the domain’s document root. - The system ignores directives that are not allowed in
.user.inifiles.
- Do not set the
- The
php.inifile that exists in the same directory as the PHP script. - The
.inifiles in the PHP version’s/opt/cpanel/ea-php##/root/etc/php.d/directory.Note:PHP scans the files in alphabetical order. To see the files that PHP loaded, you can run the
php_ini_scanned_files()command or run PHP with the-- inioption. - The PHP version’s global
php.inifile. - The PHP default setting.
If you specified a location for your .ini file, the system does not load configurations in the /opt/cpanel/ea-php##/root/etc/php.d/ directory. Instead, it loads the settings in the php.ini file that the directive specifies. We strongly recommend that you do not specify the location of a php.ini file.
The presence of one of the following sets the location of .ini file that the system reads:
- The
suPHP_ConfigPathdirective. - The
[phprc_paths]section of thesuphp.conffile. - If you set a file location with the PHPRC environmental variable.
- We strongly recommend that you do not set the
[phprc_paths]section, thesuPHP_ConfigPathdirective or set the PHPRC environmental variable. Unexpected behavior may occur. - If you specify the location of an
.inifile, you must provide a complete.inifile. Run the following command to ensure that your users receive a completephp.inifile:
cat /opt/cpanel/ea-php##/root/etc/php.ini /opt/cpanel/ea-php##/root/etc/php.d/*.ini > /path/to/specified/php.ini