Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

macos

apache

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?

like image 725
Brieuc Avatar asked Jan 09 '15 13:01

Brieuc


People also ask

What is PHP INI settings?

The php. ini file is the default configuration file for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits. php.


Video Answer


2 Answers

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
like image 199
Gergely Havlicsek Avatar answered Sep 19 '22 15:09

Gergely Havlicsek


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.

like image 29
Oskar S. Avatar answered Sep 16 '22 15:09

Oskar S.