Back to PHP (Applications and Scripts)

How To Set Up Custom PHP.INI Settings

Please note that much of what is described here is best accomplished through the command line. For this, you will need an SSH client, such as Putty, and jailshell will need to be enabled on your account. Putty can be downloaded from, and jailshell can be enabled on your account simply by contacting support and requesting it.

This file should have 644 permissions with the owner cpanelusername:cpanelusername

Let’s assume your cpanel username is bobbob1. Your php.ini file should look like this in your file manager or FTP client:

-rw-r--r--   1 bobbob1 bobbob1  21 Nov 20 18:57 php.ini

While you can simply create a blank php.ini file, and then enter the values you need to override, there are security concerns with this method. Php will revert to an absolute base configuration, which means some applications may throw a fit because certain extensions aren't enabled. A way around this is to copy the system php.ini. This can be accomplished through jailshell using the following command:

cp /opt/cpanel/ea-php56/root/etc/php.d/local.ini > /home/USERNAME/public_html/php.ini

Where USERNAME is stated, please replace it with your cPanel username. This command will copy the file into the directory you are currently in (if you just logged in, it's most likely your home directory).

Now that you have created your php.ini file, you can populate it with the php configuration values you need to override on the server.

The syntax generally follows this format:

phpconfigValueToOverride = value

For example, say the server default for upload_max_filesize is 2M (megabytes).  You can override this value by creating your own php.ini file and entering a line like this:

upload_max_filesize = 10M

This would set the new php upload limit to 10 megabytes.

Other common configuration changes include upload_tmp_dir, display_errors, session.save_path, etc...

You can check your current PHP settings by using the phpinfo() function. Simply place phpinfo(); in a new file with a .php extension.

Generally, when you create custom php.ini the changes will only have an effect on the scripts in the same directory. This can be changed by making the php.ini apply recursively. This is accomplished by entering the following code into a .htaccess file:

#Use local php.ini file recursively from public_html
SetEnv PHP_INI_SCAN_DIR /opt/cpanel/ea-php56/root/etc/php.d/:/home/USERNAME/public_html/

As before, where USERNAME is stated, please replace it with your cPanel username.  This line of code would make the php configuration values in your public_html/php.ini file apply to all subdirectories where you place the .htaccess file.

The most common setup is to place your custom php.ini at public_html/php.ini, and then place the .htaccess file at public_html/.htaccess.

Please feel free to contact our support department if you have any questions about configuring these files.

Related Articles

How To Correct PHP Issues Related To The PHP 7.4 Upgrade
PHP 7.4 and MariaDB 10.3 Upgrade Schedule
PHP 7.3 and HTTP/2 Upgrade Schedule
How To Correct PHP Issues Related To The PHP 7.3 Upgrade
PHP 7.2 Release Notes

Can’t Find what you need?

No worries, Our experts are here to help.