0

CHALLENGE

I changed the date.timezone in the php.ini file, and when I entered php-i in my terminal, it showed me the correct date.timezone, however the new date.timezone wasn't reflecting in my <?phpinfo() page on localhost.

THINGS I TRIED

I know that when a change is made to the php.ini file, the server has to be restarted. I am using the built in Apache server on MacOS, and the commands I have used so far are

  • sudo apachectl restart
  • sudo apachectl graceful
  • apachectl -k restart

All these failed to reflect the new date.timezone in my phpinfo() localhost page, when I refreshed the page.

HOW I SOLVED THE CHALLENGE

I had a similar issue in the past with this same configuration, when I changed the default php version on my laptop. The terminal command php -v showed the new version, but the <?phpinfo() page wasn't reflecting the new version, even after using the Apache restart commands stated above and refreshing the page. On a whim, I decided to restart my laptop and the <?phpInfo() localhost page reflected the new php version.

I decided to restart my computer after many painful attempts at restarting my Apache server and refreshing the <?phpinfo()localhost page didn't reflect the new date.timezone - it worked.

QUESTION

Why do I need to restart my computer for changes to be reflected in the <?phpinfo()localhost page? It doesn't seem right to me.

Tony
  • 1,414
  • 3
  • 9
  • 22
  • If PHP is running in [FPM mode](https://serverfault.com/questions/189940/how-do-you-restart-php-fpm), or similar, you might need to reload that process instead. – Chris Haas Jan 08 '21 at 00:32
  • How do I know what mode it is running in, @ChrisHaas? Also, I used `brew services restart php@7.4` and it still didn't solve the problem. – Tony Jan 08 '21 at 01:43
  • Maybe this helps you: https://stackoverflow.com/questions/12892331/do-i-need-to-restart-apache-after-changing-the-php-ini-file – Melvin Jan 08 '21 at 01:47
  • @Tony, unfortunately I don't have a Mac available right now for testing, but hopefully Melvin's post gets you there. On Linux, we'd do something like `sudo service php7.4-fpm reload`. – Chris Haas Jan 08 '21 at 02:29
  • Also, the reason that your CLI is always up to date is that the CLI re-loads the .ini (and .conf files) each time it is run. The FPM process does the same, however it is continuously running so you need to stop and start it. – Chris Haas Jan 08 '21 at 02:31
  • Thanks, @Melvin and Chris for your help. – Tony Jan 08 '21 at 08:42

0 Answers0