The cPanel PHPRC PHP Patch for EasyApache 4
Last modified: August 23, 2024
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
.ini
files and directives as it finds them. This guarantees the most predictable results. - We strongly recommend that you do not specify a location for your
.ini
file with the[phprc_paths]
section of thesuphp.conf
file, thesuPHP_ConfigPath
directive, or set the PHPRC environmental variable. Unexpected behavior may occur.
- The
.user.ini
file that exists in the same directory as the PHP script.Important:- Do not set the
user_ini.filename
directive. - If the system does not find a
.user.ini
file, 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.ini
files.
- Do not set the
- The
php.ini
file that exists in the same directory as the PHP script. - The
.ini
files 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-- ini
option. - The PHP version’s global
php.ini
file. - 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_ConfigPath
directive. - The
[phprc_paths]
section of thesuphp.conf
file. - If you set a file location with the PHPRC environmental variable.
- We strongly recommend that you do not set the
[phprc_paths]
section, thesuPHP_ConfigPath
directive or set the PHPRC environmental variable. Unexpected behavior may occur. - If you specify the location of an
.ini
file, you must provide a complete.ini
file. Run the following command to ensure that your users receive a completephp.ini
file:
cat /opt/cpanel/ea-php##/root/etc/php.ini /opt/cpanel/ea-php##/root/etc/php.d/*.ini > /path/to/specified/php.ini