Configuration: I run a web server with RHEL7 with the SELinux kernel module and php-fpm. By default, RHEL7 ships with PHP 5.4. This version of PHP is too old for my software, so I've upgraded to PHP 5.6.25 from RHSC.

Before upgrading, everything was working as expected.

When I run the upgraded php from the CLI, everything works fine. For instance, I've changed the value for upload_max_filesize (on line 810) from 2M (the default) to 8M, and this change appears as expected when I query the PHP settings from the CLI:

php -v
php 5.6.25 (cli) ...
php -i | fgrep upload_max_filesize
upload_max_filesize => 8M => 8M

However, after the upgrade, it looks like php.ini is no longer read by read by Apache when Apache is restarted. I.e.: the changes to php.ini have no effect (all values, including the value for upload_max_filesize stay at their defaults).

I've created a web-page to debug this, it contains the following snippet of PHP code:

$inipath = php_ini_loaded_file();
echo '<p>Loaded php.ini: <code>' . $inipath . '</code>.</p>';
$contents = file($inipath);
if ($contents) {
  echo '<p>Line 810: ' . $contents[810] . '.</p>';
} else {
  echo '<p>Unable to read php.ini file.</p>';
echo '<p>ini_get(): upload_max_filesize = ' . ini_get('upload_max_filesize') . '.</p>';

It outputs:

Loaded php.ini: /etc/opt/rh/rh-php56/php.ini.
Line 810:  upload_max_filesize = 8M.
ini_get(): upload_max_filesize = 2M.

I.e. the path to the php.ini used by the webserver is /etc/opt/rh/rh-php56/php.ini, and it sets upload_max_filesize to 8M on line 810. Still, the value returned when I call ini_get('upload_max_filesize') is the default. (Yes, I have restarted Apache).

There are nothing that sets upload_max_filesize in other .ini files or in .htaccess (I've searched extensively).

I have now exhausted my options for debugging, and hope for answers that will suggest how I can crack this.


Figured it out at last!

It turns out that restarting Apache (httpd) is not enough to make changes to php.ini take effect with this particular configuration. You also need to restart the FastCGI Process Manager. The following command resolved it:

sudo systemctl restart rh-php56-php-fpm.service
  • To change the PHP configuration when using php-fpm, you don't need to restart Apache at all, only PHP. – Michael Hampton Jan 19 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.