How to best locate/manage multiple PHP.ini config files?

3 posts / 0 new
Last post
#1 Wed, 11/07/2018 - 07:14
cron

How to best locate/manage multiple PHP.ini config files?

A quick locate php.ini results in this:

/etc/php.ini
/etc/php.ini.rpmsave
/etc/opt/remi/php72/php.ini
/etc/opt/rh/rh-php56/php.ini
/etc/opt/rh/rh-php70/php.ini
/etc/opt/rh/rh-php71/php.ini
/home/testuser/etc/php.ini
/home/testuser/etc/php5/php.ini
/home/testuser/etc/php5.5/php.ini
/home/testuser/etc/php5.6/php.ini
/home/testuser/etc/php7.1/php.ini
/opt/remi/php72/root/usr/share/doc/php72-php-common-7.2.11/php.ini-development
/opt/remi/php72/root/usr/share/doc/php72-php-common-7.2.11/php.ini-production
/opt/rh/rh-php56/register.content/etc/opt/rh/rh-php56/php.ini
/opt/rh/rh-php56/root/usr/share/doc/rh-php56-php-common-5.6.25/php.ini-development
/opt/rh/rh-php56/root/usr/share/doc/rh-php56-php-common-5.6.25/php.ini-production
/opt/rh/rh-php70/register.content/etc/opt/rh/rh-php70/php.ini
/opt/rh/rh-php70/root/usr/share/doc/rh-php70-php-common-7.0.27/php.ini-development
/opt/rh/rh-php70/root/usr/share/doc/rh-php70-php-common-7.0.27/php.ini-production
/opt/rh/rh-php71/register.content/etc/opt/rh/rh-php71/php.ini
/opt/rh/rh-php71/root/usr/share/doc/rh-php71-php-common-7.1.8/php.ini-development
/opt/rh/rh-php71/root/usr/share/doc/rh-php71-php-common-7.1.8/php.ini-production
/usr/share/doc/php-common-5.5.38/php.ini-development
/usr/share/doc/php-common-5.5.38/php.ini-production

Needless to say this list is a bit overwhelming and is only going to get longer as I add servers.

Three questions:

  1. Which files are copied to new servers as they're created? I guess if I get these in order at the start, I'll have fewer modifications to make later.
  2. Is there some way to keep a root php.ini which controls all servers?
  3. What is the best practice for managing all this?

Thank you

Wed, 11/07/2018 - 17:45
marcelorp

I think that is better to have a root php.ini file for security reasons and performance...for me, clients don't have to get too much access to that, they can ask to you for changes. Or you can use PHP-FPM to force some settings as root, and let your users controls the others settings, and either they edit php.ini, your PHP-FPM values will overwrite all that. But with PHP-FPM you wont have multiple php versions =(

For PHP-FPM you have to just setup your /etc/php-fpm.d/xxxxxxxx.conf these directives as example:

php_admin_value[session.save_path] = /home/codebr/tmp
php_admin_flag[allow_url_fopen] = Off

In PHP-FPM you have 4 ways to set PHP variables:

php_value[name] = value Don't overwrite users php.ini file, just setup if they don't.
php_flag[name] = on/off Don't overwrite users php.ini file, just setup if they don't.
php_admin_value[name] = value Overwrite users php.ini file.
php_admin_flag[name] = on/off Overwrite users php.ini file.

For a ROOT php.ini you should go to System settings -> Servers Template -> Default Settings -> PHP Options -> Allow editing of PHP configuration? -> No and in that same tab, have fields to manage where are your default template file for php.ini.

Fri, 11/09/2018 - 03:43 (Reply to #2)
cron

Hey thanks for this. I'm gonna go with a root php.ini for now and may branch off that later if needed. Cheers