Global php.ini for PHP-FPM

Rockyuk

Verified User
Joined
Aug 3, 2020
Messages
59
Hello Everyone,
I have been scratching my head at this for days it was initially working but has not stopped. I used to be able to adjust global php.ini via path /usr/local/php81/lib/php.ini but now it does not seem to work. Then i tried the php-fpm conf file again does not work, what is the correct way for global php settings please? If I add a .user.ini file into the websites root direct the settings work fine.

My setup is Apache & Nginx as Reverse Proxy, Cloudlinux 8

Thanks

Rockyuk
 
I don't use cloudlinux or nGinx.

But normally, the first PHP version is responsible for the global php.ini used by default.
If php 8.1 is not the first php version (in custombuild) then the domain used, needs to choose php 8.1 version to get the php 8.1 php.ini file affective.
 
could you explain more detail.

what do you want to do ?
what's setting do you need ? memory_limit or something else ?
 
Unfortunately the global 8.1 is not working I like to set global post size, upload max size etc
 
It impacts all accounts, like I mentioned if I do user.ini file in a specific domains root folder it will override the settings. Or if you do it per domain through the control panel settings it will override the settings.

The issue with that is the non technical people who just know the basics won't be able to do it. That is why I always do stuff globally so clients don't have to think about it.
 
You can find the php.ini file that a particular PHP is reading from with:

/usr/local/php81/bin/php -i | grep "Loaded Configuration File"

Or if you are referring to a different PHP version

/usr/local/phpXX/bin/php -i | grep "Loaded Configuration File"
 
Yeah it is
Odd.
Then you should be able to use the one you are used to:
/usr/local/php81/lib/php.ini
and ofcourse restarting the php-fpm81 service after making the changes. And all domains are set to php 8.1 too or use the default.

I hope there is no symlink left anywhere. Maybe the commands @sparek gave can shed more light into which php.ini is in effect globally.

I presume you do not have created a 99-custom.ini (or something like that) in the /usr/local/php81/lib/php.conf.d/ directory?
 
Odd.
Then you should be able to use the one you are used to:

and ofcourse restarting the php-fpm81 service after making the changes. And all domains are set to php 8.1 too or use the default.

I hope there is no symlink left anywhere. Maybe the commands @sparek gave can shed more light into which php.ini is in effect globally.

I presume you do not have created a 99-custom.ini (or something like that) in the /usr/local/php81/lib/php.conf.d/ directory?
/usr/local/php81/bin/php -i | grep "Loaded Configuration File"
Loaded Configuration File => /usr/local/php81/lib/php.ini

This is the edited php.ini and no I don't have a custom.ini anywhere. Not sure why it stopped working as it was before.
 
Ok, so I decided to go through the php-fpm selector from 7.4-8.2 and all of the other versions seem to work globally just not version 8.1? Also 8.1 is the default for the server as well.
 
You can see all of the additional ini files that PHP is loading by default with:

/usr/local/php81/bin/php -i | sed ':a;N;$!ba;s%,\n% %g' - | grep "^Additional .ini files parsed"

Again replacing php81 with whatever version of PHP you are wanting to check

It is possible to tell PHP-FPM to use an alternate php.ini file when it is loaded. You would do this by passing a -c /path/to/php.ini to the ExecStart line in the systemd config file.

By default for DirectAdmin the PHP 8.1 systemd file would be:

/etc/systemd/system/php-fpm81.service

So you could run:

cat /etc/systemd/system/php-fpm81.service | grep ^ExecStart

But honestly, you'd have to know that you did this for this to be changed.
 
You can see all of the additional ini files that PHP is loading by default with:

/usr/local/php81/bin/php -i | sed ':a;N;$!ba;s%,\n% %g' - | grep "^Additional .ini files parsed"

Again replacing php81 with whatever version of PHP you are wanting to check

It is possible to tell PHP-FPM to use an alternate php.ini file when it is loaded. You would do this by passing a -c /path/to/php.ini to the ExecStart line in the systemd config file.

By default for DirectAdmin the PHP 8.1 systemd file would be:

/etc/systemd/system/php-fpm81.service

So you could run:

cat /etc/systemd/system/php-fpm81.service | grep ^ExecStart

But honestly, you'd have to know that you did this for this to be changed.
/usr/local/php81/bin/php -i | sed ':a;N;$!ba;s%,\n% %g' - | grep "^Additional .ini files parsed"
Additional .ini files parsed => /usr/local/php81/lib/php.conf.d/10-directadmin.ini /usr/local/php81/lib/php.conf.d/50-webapps.ini /usr/local/php81/lib/php.conf.d/clos_ssa.ini

This is what comes up after running the first command
 
If whatever PHP directive you are wanting to change is also being changed in any of those additional files, then you will probably need to make the change in that additional file.

There's not a complete picture of what you are wanting to do so I can only provide steps that might lead you to an answer.
 
There's not a complete picture of what you are wanting to do
He stated that in post #4.
I like to set global post size, upload max size etc

Seems only the clos_ssa.ini is non-default, but I doubt if that will contain any post size limits or things like that.
Maybe changes he mad in php-fpm conf or something? I don't have a clue on where to have him look either.
 
Back
Top