Php – File php.ini configuration on Mac OS X

apachemacosPHP

I am experiencing a strange problem with PHP configurations file php.ini on Mac OS X. 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?

Best Answer

I'm using native Mac OS X Apache 2 with Homebrew taps from josegonzales.

To quote my system administrator 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 p-list 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 file 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;}

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