Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File php.ini configuration on Mac OS X

Tags:

php

macos

apache

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?

like image 681
Sarthak Gupta Avatar asked Mar 16 '12 07:03

Sarthak Gupta


People also ask

Where is PHP ini on Mac Catalina?

ini File at MacOS Catalina. For my MacOS Catalina, the location of php. ini is located at /etc/. As you can see there is no php.

How do I run a PHP file on Mac OS X?

Use the Built-In Apache Web Server to Run PHP on Mac We can use the command sudo apachectl start in the terminal to start the webserver. Then, typing the URL http://localhost/index.php where our PHP file is index. html will run the PHP file. The PHP file should be in the root directory to run.

Where is PHP ini file in xampp Mac?

ini file: Whenever we install PHP, we can locate the configuration file inside the PHP folder. If using xampp, we can find the configuration file in one or many versions, inside the path '\xampp\php'.


1 Answers

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.

like image 163
Jeremy John Avatar answered Oct 22 '22 18:10

Jeremy John