Getting custom user php.ini per domain on cPanel/WHM to work

In this article i want to highlight the issue that just allowing user to override php.ini (PHP config file) is not enough to make it work. You still need to change a line in local.ini so that PHP handler knows where to look for the user's php.ini in the domain webroot directory. Before i continue, I'm making changes for PHP 5.6 and using fcgi as the PHP handler. 

If you are currently running CentOS 7 with cPanel/WHM 58, you will notice even though the php.ini is written to the domain's directory of your choice after you have made changes using the PHP editor in cpanel, it still doesn't override the default values.

This is because we still need to tell PHP handler where the location path is to your custom php.ini. To fix this, we need to modify a line in the local.ini that PHP looks into for which global values the system uses. See: https://documentation.cpanel.net/display/EA4/The+cPanel+PHPRC+PHP+Patch+for+EasyApache+4  

What we need to do is open the file (local.ini) and modify a line:

nano /opt/cpanel/ea-php56/root/etc/php.d/local.ini

Find this line in local.ini:

;user_ini.filename =

and simply uncomment that line and add php.ini and save the file, as shown below:

user_ini.filename = "php.ini"

Finally, restart Apache web server so it will pick up the new changes.

service httpd restart

Now it should pick up the user php.ini file to override the default value.

 

The content of this field is kept private and will not be shown publicly.
Your email address will be kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.