Setting custom php.ini files for your website

Many of us have wondered, how can we change some of the PHP directives to match some script requirements? Even though this might sound complicated, it is much easier than it looks.

First, we should know a few facts about PHP directives and where they reside. We have 3 levels of php.ini file levels:

1)      Server global php.ini (this file resides in the server configuration and this cannot be edited by the users in a shared hosting environment).

2)      User global php.ini (this file usually resides in the main folder for a user website, like public_html and this serves all the php scripts that fall under the user account).

3)      User local php.ini file (this file is not limited to a specific path and can be deployed by the user wherever he feels he needs to change some parameters for some script).

Now, an interesting question arises: how does this work? The answer is pretty simple. PHP interpreter looks for the php.ini files from down upwards, meaning it looks for a user local file, if the file is not there, it looks in the folder above and then above until it reaches the main folder for the user account. If it fails to find any custom user php.ini file, the interpreter reverts to the global php.ini file for directives.

This is very useful for creating custom php.ini files. You can have the global file serve all your PHP directive needs. If you need a certain directive overwritten (we will show how soon), you simply create a php.ini file in the folder where your script resides, and add that directive. The changes will only affect script files running on this folder and any subfolders below that folder. Parent folders will revert to the php.ini file in their respective folder or their parent folder, and so on.

Now, how to create a php.ini file? This also seems like rocket science (this analogy is obsolete nowadays) but it is very simple. There are 2 ways of doing this:

– Login into your control panel, open your favorite file manager, in my case, it is “file manager”.

– Navigate to the folder you wish to add the file, click on “new file”, enter the name of the file which is php.ini (please note that this is the only acceptable file name, all lowercase).

– Open the file in the editor by clicking on the edit button. And add the parameters you wish to change in the following order:

variable = value;
variabl2 = value2;

In my case, it is the following:


max_execution_time = 60;

memory_limit = 256M;

upload_max_filesize = 256M;

post_max_size =  256M;

– Save the file and exit.

The second way you can add this file is by logging onto your FTP and adding the file or uploading it after creating it locally.

The last portion of this tutorial will discuss how to check if your changes have been reflected or not and what php.ini file is actually being used to process scripts in a specific location. You can create a PHP file (using the same steps as above) with the following content:




You have to go to your browser and open the PHP file. This script will simply display all the information for your PHP environment. We are now interested in one field, the “loaded configuration file”. This directive will show you which file is being used to obtain the directives for the PHP file you just created and executed.

Please note that you only need to include the directives which values you want changed and not all the values that are globally defined.

Tags: , , , , , | Posted under CGI, cPanel Tutorials, cPanel/Linux Hosting, Customization, PHP.ini | RSS 2.0

12 Comments on Setting custom php.ini files for your website

  1. anon says:


    Your website appaently has a bad certificate. I am looking into hosting with you.

  2. antefire says:

    thank you, saved me a lot of headaches

  3. Gangesh says:

    Thank you! 🙂

  4. Kevin says:

    Hello, I’m trying to turn display_errors off from php.ini, but my loaded configuration file is somewhere I don’t recognize and can’t even find from my file manager. It starts with /usr/local/. Can you help me find out where that is?

  5. Hello,

    I have my own php.ini in the html folder, also I created the php file to be sure that the configuration is based on my file and not on the server file, but it still doesn´t let me upload files bigger than 2Mb and I put with different values in my php.ini (5mb, 256mb, 10mb) and nothing works.

    Can you help me to change the maximum upload file size?


  6. Albert says:

    Hi! I’m considering to contract the personalClass plan but I need to know if there’s a maximum value for: max_execution_time, memory_limit, upload_max_filesize, post_max_size. If there is, can you tell me which value for each parameter? Thanks!

  7. Eric says:

    Hi, I wanted to change the max upload size with your script for ownCloud. I created the php.ini file but every time I open the owncloud site there is only a white screen. If I delete the .ini file everything is normal again.

    • Alex says:


      I recommend you reach out to our support team at support @ They should be able to locate the issue causing the white screen and/or change the max upload size.



Leave a Reply

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