How to set default php.ini to be used, OSX Yosemite

46,375

Solution 1

move the configuration file to the right spot and update the timezone.

$ sudo cp /etc/php.ini.default /etc/php.ini

Open the config file /etc/php.ini, find the line that sets your timezone and update it correspondingly.

date.timezone = Europe/Berlin

Do not forget to remove the ; at the beginning. Restart the Apache server to have PHP load the new .ini file.

sudo apachectl restart

Solution 2

On mac sierra with php7.1, edit /usr/local/etc/php/7.1/php.ini won't work, you can edit like this:

1) cp /etc/php.ini.default php.ini
2) edit php.ini to add
date.timezone = Europe/Berlin

then restart your apache,

Solution 3

SAPI module specific location (PHPIniDir directive in Apache 2, -c command line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH environment variable in THTTPD)

http://php.net/manual/en/configuration.file.php

Try changing PHPIniDir in httpd.conf.

Share:
46,375
Brieuc
Author by

Brieuc

Full-stack developer (PHP, Symfony, WP, VueJS, React, Angular, Typescript). CTO 30+ employees startup. A true believer of distributed & remote teams. Self-taught in programming. Studied computer science & Information system. Strong: PHP, Javascript, MySQL, problems solving. Also: Firebase/Firestore, Ionic/Capacitor, API Platform.

Updated on July 23, 2022

Comments

  • Brieuc
    Brieuc almost 2 years

    I set up a new environment using OSX Yosemite.

    I'm using the built-in PHP.

    I'd like to change some config in php.ini such as date.timezone but none of the modifications are working despite restarting the apache server (sudo apachectl restart).

    phpinfo() is giving a different path than php --ini command.

    phpinfo():

    Configuration File (php.ini) Path /usr/local/php5/lib

    Loaded Configuration File /usr/local/php5/lib/php.ini

    Via commands :

    which php

    /usr/bin/php

    php --ini

    Configuration File (php.ini) Path: /etc

    Loaded Configuration File: /etc/php.ini

    Scan for additional .ini files in: /Library/Server/Web/Config/php

    Additional .ini files parsed: (none)

    So I guess I have to tell somewhere where I should set the default php.ini to be used.

    Any ideas, hints?

  • Brieuc
    Brieuc over 9 years
    Sorry, that didn't really help. I still can't figure it out where i can change it. I didn't find any PHPIniDir or Anything similar in my httpd.conf
  • Oskar S.
    Oskar S. over 9 years
    Have you tried to add it to httpd.conf? Also, see stackoverflow.com/a/10386320/1479812
  • Brieuc
    Brieuc over 9 years
    Almost but i don't know why it takes /private/etc/php.ini and not /etc/php.ini. I set it like that PHPINIDir "/etc/php.ini"
  • Sanjay Verma
    Sanjay Verma about 8 years
    Just to add, if someone is wondering where to find the 'right' php.ini (and above one is not working), see serverfault.com/a/466625/351759.
  • Hyder B.
    Hyder B. about 8 years
    Worked for me on El Capitan