Often, we create a custom php.ini file within public_html to temporarily modify certain PHP values within our domain. However, this file is not inherited as the php values in .htaccess were, it only effects the directory it is located in. If you are setting up custom php settings, the custom php.ini file will be required in a folder where the php script needs to execute.

Let us look at a scenario.

Assume you have Joomla installation under your public_html directory. Every time you try uploading an template (which is over 2MB in size) via the extension manager, you encounter an error saying your upload size is limited to 2MB. Hence you create a custom php.ini file in your public_html directory.

The custom php.ini file will have the following entry in it.

upload_max_filesize = 4M

This will override the default PHP setting of 2M for upload_max_filesize. You can also verify this by creating a PHP Info page.

However for any subdirectory of public_html, the value of upload_max_filesize will still remain 2M, i.e, the administrator directory within your Joomla installation will still have the upload_max_filesize set to 2M. Every time you try to upload a file which is above 2MB in size via your extension manager, you’ll still encounter the same ‘upload limit’ error.

Creating a local php.ini file in every subdirectory, is not the ideal solution to this. In order to get the values of your php.ini file placed in public_html to be inherited by all the subdirectories, you will need to add the following lines to the .htaccess file in your public_html folder:

suPHP_ConfigPath /home/username/public_html
<Files php.ini>

order allow,deny

deny from all


This will make php look for a php.ini file in the public_html folder. It is important to leave off the trailing slash and to not specify a filename, the file must be called php.ini. ‘username’ is your cPanel username. If you need different php settings in a particular subdirectory, then simply place a php.ini file in that directory and it will override the main php.ini in the public_html folder.  The <Files> section ensures that no one can view the php.ini file from the internet.

Leave a Reply

Your email address will not be published. Required fields are marked *