S S

Linux support on-site, on-line and in the cloud.

0793 572 8612

Systems Administration Notes.

When php.ini appears to be ignored.


When php.ini appears to be ignored.

I recently set up a virtual Centos 8.2.2004 server running Moodle for a client.

I needed to up the maximum size of file uploads. Straight forward surely? Edit php.ini and restart apache. Checked the Moodle documentation just to be sure but no, the change was not registered in Moodle.

Could there be another php.ini? Searched the whole system.

find / -name php.ini

No, there is only one: /etc/php.ini

Tried setting creating phpinfo script

<?php
     phpinfo();
?>

and checked the configuration through the web, still the old values..

Tried stopping Apache and checking with ps that all instances had been killed. Then restarted. Did this with apachectl and with systemctl, the situation remained the same. Was it possible that mod_php was still running?

Further investigation showed that mod_php was not loaded even when Apache was running. Cutting a long story short, further study determined that mod_php is now considered old hat and that the modern way is through fast CGI or rather more specifically on Centos at least php-fpm (fastCGI Process Manager).

I had combed Google quite assiduously looking for others that experienced php.ini being ignored and had found many queries at all the usual linux expert sites, none of them had found a solution which is a puzzle.

What is happening is that when Apache httpd is started it also starts php-fpm. The daemon process php-fpm loads a copy of the php interpreter and listens on a UNIX socket for requests to run php scripts. When httpd is stopped either by apachectl or systemctl this has no effect on php-fpm. It doesn’t matter if we stop, start, restart or reload httpd, php-fpm just keeps on running having read php.ini just once at start up. Changes to php.ini have no effect whatever you do to httpd. I can’t swear that this is the case on every Linux distribution but judging by the questions you can find through Google it does affect a fair few.

Stopping and starting or restarting php-fpm solves the problem but in fact its even easier than that.

Make the changes to php.ini and then reload, not httpd but php.fpm.

systemctl reload php-fpm

The new values are then available and there is no interuption to your web services.

Clifford W Fulford
30 Novermber 2020.



The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.