Cloudlinux + CageFS + PHP Selector - how to update default php.ini for each PHP version?

ShawnL

Member
Mar 3, 2016
9
0
1
US
cPanel Access Level
Root Administrator
My server runs Cloudlinux 5.11 with CageFS and PHP Selector. Default PHP version is 5.3.

I have one account using PHP 5.3, one account using PHP 5.5, and one account using PHP 5.6.

I'm trying to figure out how to update each account's php.ini or each PHP version's default php.ini.

So far I've figured out how to update PHP 5.3's default php.ini:

1. `phpinfo` on the PHP 5.3 account shows the loaded configuration file is from `/usr/selector.etc/php.ini`.

2. Update /usr/local/lib/php.ini

3. Run `cagefsctl --force-update`

4. Rebuild Apache

Then the modified `/usr/local/lib/php.ini` is reflected on the `phpinfo`.

However, for PHP 5.5. and 5.6 accounts, I can't figure out how to update their default php.ini's.

1. Their `phpinfo` shows the loaded configuration files are from `/opt/alt/php55/etc/php.ini` and `/opt/alt/php56/etc/php.ini`

2. Update those files

3. Run `cagefsctl --force-update`

4. Rebuild Apache

Afterwards, the changes of these php.ini's are reverted! So where is the right place to change these PHP versions' default php.ini's?

Being able to update each PHP version's default php.ini would work for me, but it would be even easier and more flexible if each domain account (or even each folder) can have its own php.ini.

I've tried `/public_html/php.ini` and `/public_html/.htaccess`. They don't take effect at all. `ini_set` in script works though, but of course I don't want to reply on just `ini_set`.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Hello :)

Cloud Linux documents this at:

CloudLinux Documentation

Per the document:

Default values, that are shown in PHP-Selector web interface, are taken from '/opt/alt/phpXX/usr/bin/php -i' runtime values, if directive is not there, it will use 'default' value that was set in php.conf . So, if you wish to change default value of any option for "alternative" php version, please modify /opt/alt/phpXX/etc/php.ini files (where XX = 55, 54, 53, etc according to php version).
Could you verify if the issue persists if you run the "cagefsctl --rebuild-alt-php-ini" command after editing the files?

Also, as far as individual users, this is documented at:

CloudLinux Documentation

Thank you.
 

ShawnL

Member
Mar 3, 2016
9
0
1
US
cPanel Access Level
Root Administrator
After modifying /opt/alt/php55/etc/php.ini

Running "cagefsctl --rebuild-alt-php-ini" WORKS!!

Looks like the default PHP version and alternative versions have different php.ini update processes.

To update an individual user's php.ini, do I go to "/etc/cl.php.d/alt-phpXX/alt_php.ini" ?

And then run ""cagefsctl --rebuild-alt-php-ini" ?

When I try to enter CageFs for a user, I got error:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Invalid argument
chdir: error retrieving current directory: getcwd: cannot access parent directories: Invalid argument

Is it normal? I can still locate "/etc/cl.php.d/alt-phpXX/alt_php.ini" though.

Thanks a lot!!
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
I am happy to see the issue is now resolved. Note you can view the "Individual PHP.ini files" section under "Configuration" in the document referenced in my earlier post. As far as the additional error messages, please open a new thread as that does not appear to be related to the original issue.

Thank you.
 

dialhost

Member
PartnerNOC
Jun 17, 2005
5
0
151
Hello :)

Cloud Linux documents this at:

CloudLinux Documentation

Per the document:



Could you verify if the issue persists if you run the "cagefsctl --rebuild-alt-php-ini" command after editing the files?

Also, as far as individual users, this is documented at:

CloudLinux Documentation

Thank you.

Michael,

If the user directly edit the file located in /home/user/.cl.selector/alt_phpxx.cfg, the rebuild will then disregard the options that the administrator has allowed to be changed in php.conf

It is true that user may not use the interface again, otherwise overwrites the .cfg, but if the user edit this file and another user or administrator run the rebuild command, the settings will be overwritten for that user.

What you think about this? Would be a Security breach?

I think is a validation would be needed and apply only what is in php.conf and disregard anything in the .cfg file?

Thanks.
Flavio
DialHost from Brazil
 

dialhost

Member
PartnerNOC
Jun 17, 2005
5
0
151
Michael,

You can reproduce with the following steps:

First:
Save the settings on the interface to the desired settings and are also allowed by the php.conf

Second:
It will be created the directory /home/USER/.cl.selector/ with cfg file.

Third:
Edit the corresponding cfg file to version.
vi /home/USER/.cl.selector/alt_phpxx.cfg

Add such a function that was not allowed in php.conf
like:
disable_functions = "";

Fourth:
Reduild the php.ini
cagefsctl --rebuild-alt-php-ini

You will notice that does not validate the function that is described in the .cfg file.

I know if change again in the interface, the cfg file is modified.
But you can change this config file and wait for rebuild. So the configuration it will be validated.

Can you understand the steps?

Thanks.