Which php.ini is used when they appear in multiple directories

Kerrya

Member
Jul 27, 2013
18
1
53
cPanel Access Level
Reseller Owner
Which php.ini is used when they appear in multiple directories?

I've always thought the order of use was from the furthest down directory and then up to the home directory of the user.

For instance, if a php.ini file exists in the public_html directory, the php.ini in the home directory was not used. A bottom up approach.

But an experience today leads me to thing it's top down meaning the php.ini in the home directory is used and the public_html directory ignored.

But if this is the case, How do you set a different php.ini for each addon domain?

Any help appreciated.

Kerry
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
10,416
1,633
363
cPanel Access Level
Root Administrator
Hey there! Let's use the addon domain like you mentioned as an example. In this case, you'd get a directory created in /home/username/addon_domain_name. Through cPanel >> MultiPHP INI Editor you can choose the directory you're working with from the dropdown menu, and that will create the local ini file.

At this point, we can create a phpinfo page inside our addon_domain_name directory. If we load that page in our browser we'll see both the local value and master value in each column for each configuration option, but I do see the local value takes precedence.

Could you let us know what specific PHP option you're experiencing the conflict with? It should be reading from any local .ini and then upward, as you anticipated.
 

Rachel S

Member
Apr 28, 2022
18
4
3
United States
cPanel Access Level
Website Owner
It is possible to create the different php.ini for the addon domain below are the steps for the same.

Login to cPanel and choose the version of your php, now clicking on the save button will copy the server's master php.ini to your public_html directory as "php.ini.default"

Move the file to the addons folder and rename it to php.in If you are using 'single php.ini' in the php config section of Cpanel, you need to create a .htaceess file in the addons folder.

Additionally, Addons. htaccess file needs to contain a regular php handler. AddHandler application/x-httpd-php7 .php