Simple question: where is the correct PHP.INI location in Mac OSX El Capitan?
I tried to update the one in /etc folder, but nothing changed.
Simple question: where is the correct PHP.INI location in Mac OSX El Capitan?
I tried to update the one in /etc folder, but nothing changed.
The default location on OSX El Capitan and macOS Sierra is /etc/php.ini
But if that file doesn't exist, php will use /etc/php.ini.default
. Don't forget to create a copy if you want to make changes:
$ sudo cp /etc/php.ini.default /etc/php.ini
Also, php will scan /Library/Server/Web/Config/php
dir for additional .ini files
Restart Apache if you made any changes:
$ sudo apachectl -k restart
Note: if you install PHP7, this location will change to
/usr/local/etc/php/7.0/php.ini
i know three ways:
<?php phpinfo();
and open the file in the browserSimple solution
create php info file in your web folder
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
open the file in browser
look for
INFO_GENERAL 1 The configuration line, php.ini location, build date, Web Server, System and more.
Taken from php manual
Another option is to use
<? php_ini_loaded_file(); ?>
Strange thing that phpinfo() does not display the file location, but here it is: /etc/php.ini.default
ob_start();
phpinfo();
$output = ob_get_clean();
preg_match("/(Loaded Configuration File => )([\/\w.]+\.ini)/i", $output, $matches);
echo $matches[2];
In my case I got:
/opt/homebrew/etc/php/8.1/php.ini
This is a polished version of "Simple solution", someone posted before
<?php phpinfo();?>