Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force reloading php.ini file?

I configured a web server last week, it worked fine.

Today I request its homepage, I see a timezone error, as it should be configured into my php.ini file.

I try a phpinfo(); on my webserver, it gives me:

Configuration File (php.ini) Path   /opt/rrh/php/lib  

But no php.ini file loaded.

I investigate, the php file exists and has very large permissions:

 ls -la /opt/rrh/php/lib     -rwxrwxrwx  1 apache root 68448 Nov 22 10:10 php.ini 

I try a parse_ini_file("/opt/rrh/php/lib/php.ini"));, it returns no error...

Of course I restart my server a dozen of time.

What can I do more to resolve my problem?

My system:

  1. Redhat 6
  2. Apache 2.4
  3. PHP 5.5.19 with libphp5.so apache module
like image 694
Fractaliste Avatar asked Dec 10 '14 09:12

Fractaliste


People also ask

How do I restore a PHP ini file?

You can restore the global php. ini file for your account or the main php. ini files of subdomains to default by using the Restore to default button from the hosting Control Panel -> PHP Settings section.

Do changes to PHP ini require restart?

PHP-FPM you need to restart to avoid configuration inconsistency. Some workers will lay dormant and keep the old configuration, while new workers will get the new configuration.

How do I reinstall PHP ini on Windows?

To restart PHP on IIS , you actually need to restart IIS : Click Start, click Run, type IISReset, and then click OK.


2 Answers

To force a reload of the php.ini you should restart apache.

Try sudo service apache2 restart from the command line. Or sudo /etc/init.d/apache2 restart

like image 99
g_uint Avatar answered Sep 24 '22 13:09

g_uint


TL;DR; If you're still having trouble after restarting apache or nginx, also try restarting the php-fpm service.

The answers here don't always satisfy the requirement to force a reload of the php.ini file. On numerous occasions I've taken these steps to be rewarded with no update, only to find the solution I need after also restarting the php-fpm service. So if restarting apache or nginx doesn't trigger a php.ini update although you know the files are updated, try restarting php-fpm as well.

To restart the service:

Note: prepend sudo if not root

Using SysV Init scripts directly:

/etc/init.d/php-fpm restart        # typical /etc/init.d/php5-fpm restart       # debian-style /etc/init.d/php7.0-fpm restart     # debian-style PHP 7 

Using service wrapper script

service php-fpm restart        # typical service php5-fpm restart       # debian-style service php7.0-fpm restart.    # debian-style PHP 7 

Using Upstart (e.g. ubuntu):

restart php7.0-fpm         # typical (ubuntu is debian-based) PHP 7 restart php5-fpm           # typical (ubuntu is debian-based) restart php-fpm            # uncommon 

Using systemd (newer servers):

systemctl restart php-fpm.service        # typical systemctl restart php5-fpm.service       # uncommon systemctl restart php7.0-fpm.service     # uncommon PHP 7 

Or whatever the equivalent is on your system.

The above commands taken directly from this server fault answer

like image 29
TCooper Avatar answered Sep 25 '22 13:09

TCooper