Do I need to restart Apache after changing the php.ini file?

PhpApache

Php Problem Overview


If I make a change to a setting in the php.ini file - do I need to restart Apache in order for it to take effect?

Php Solutions


Solution 1 - Php

Depends, actually. Depends on how you use php inside that webserver:

  • using php as module inside the http server: you have to restart the http server process
  • using php as cgi backend: you do not have to restart the http server process or anything else
  • using php fastcgi: you have to restart the fastcgi daemon, not the http server
  • using php-fpm: you have to restart the fpm server process, not the http server process

Solution 2 - Php

On Debian 8 I had to restart PHP-FPM (and Apache) The above answers are correct, but here are the commands so you won't have to googling them.

Restart Apache :

/etc/init.d/apache2 restart

Restart php5-fpm :

sudo service php5-fpm restart

Solution 3 - Php

That depends on the SAPI you're using. If you're using PHP as an Apache module for example, you need to restart apache so that the php.ini values take effect.

If you're using FCGI, you need to restart the FCGI daemon for the PHP script that you want to see the values changed. Compare with

Solution 4 - Php

It depends on what OS and version you are running.

I am running Apache/2.4.29 under Ubuntu.

PHP Version 7.2.24.

I restart apache with the following command and the restart is needed after modifying the php.ini file:

sudo service apache2 restart

Solution 5 - Php

Not sure about Apache but on Windows with IIS a restart is not required.

Either way, considering the myriad of different configurations out there with PHP, an easy way to check is to load your phpinfo.php file in a browser and confirm the value of a setting, then change that setting in php.ini and reload phpinfo.php to see if it's picking up your change.

If you don't know what I mean by "phpinfo.php" check this page: https://blogtimenow.com/knowledge-base/create-phpinfo-php-file-page/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionsimbroView Question on Stackoverflow
Solution 1 - PhparkaschaView Answer on Stackoverflow
Solution 2 - PhpKaizoku GambareView Answer on Stackoverflow
Solution 3 - PhphakreView Answer on Stackoverflow
Solution 4 - PhplcompareView Answer on Stackoverflow
Solution 5 - PhpVincentView Answer on Stackoverflow