php.ini MAC OSX上的配置

I am experiencing a strange problem with PHP configurations file php.ini on mac osx. I have created a phpinfo file. Calling it in the browser shows the php settings with -

**Configuration File (php.ini) Path : /etc

Loaded Configuration File : /private/etc/php.ini**

However upon editing the php.ini file at this location, (and restarting Apache of course) the changes are not reflected in the php settings as well as the phpinfo file. e.g.: changing the bcmath decimal digits, changing timezone settings etc. Is there another primary location from where Apache will pick up the settings file. Any help would be highly appreciated.

restarting your apache server from services panel will reflect your new changes made....

This is an old post, but I had this problem and scoured the internet to no avail, so I answer here for posterity.

I'm using native Mac OSX apache2 with homebrew taps from josegonzales.

To quote my sysadmin friend, "the answer should lie in restarting PHP-FPM instead of Apache. Apache uses mod_fastcgi to connect to PHP via a port or socket that PHP-FPM runs php with."

You need to load/unload the plist file associated with your PHP-FPM install. First check ~/Library/LaunchAgents Not there? Mine was located here: /usr/local/Cellar/php53/5.3.26/homebrew-php.josegonzalez.php53.plist

It's restarted like this: launchctl unload -w /usr/local/Cellar/php53/5.3.26/homebrew-php.josegonzalez.php53.plist && launchctl load -w /usr/local/Cellar/php53/5.3.26/homebrew-php.josegonzalez.php53.plist;

I added the following to my ~/.bash_profile so that I can restart PHP-FPM when I restart apache. The command to invoke the following is "apachectlrestart"

function apachectlrestart () { sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist && sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist && launchctl unload -w /usr/local/Cellar/php53/5.3.26/homebrew-php.josegonzalez.php53.plist && launchctl load -w /usr/local/Cellar/php53/5.3.26/homebrew-php.josegonzalez.php53.plist;}

Glassdimly's answer helped me to fix this problem.

Problem:

  • 'Loaded configuration file' shows '/usr/local/etc/php/7.0/php.ini' in phpinfo() output, and my module(imagick) is not getting loaded by php.

  • I tried manually including my module in the main php.ini file and restarting apache but 'Loaded configuration file' did not update.

  • I tried killing all instances of apache and restarting apache - still same.

  • I tried renaming my php.ini to php.ini_ and restarted apache but 'Loaded configuration file' is still showing the old php.ini file.

Solution:

  • After reading Glassdimly's answer above, I tried these steps:

  • launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist

  • launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist
  • And boom - it worked!
  • Next I set up shortcut function inside my ~/.bash_profile:

    # restart php-fpm
    function restart_fpm(){
    
        plist=~/Library/LaunchAgents/homebrew.mxcl.php70.plist
    
        launchctl unload -w $plist
        launchctl load -w $plist
    
        echo "PHP 7 fpm restarted"
    }
    
  • source ~/.bash_profile loads the new function into the current shell

Hope this helps some fellow desperate Googler from the future!