开发者

php5.3.3 date.timezone again php.ini directive not taken into account

System: Debian Lenny/Apache 2.2/php5.3.3 compiled from sources

I'm strugglying with the date.timezone within php.ini.

I can define the TZ using in the php source code but I'd like to fix that at once in the ini file.

php code : Ok

date_default_timezone_set('Europe/Berlin');

php.ini : Not taken into consideration if not setup within the source code

date.timezone = 'Europe/Berlin'

I also checked that I modified the right php.ini file and have interference with some php.default.ini files.

I checked within the apache config files whether there would be an interfering TZ env data, but none.

Don't know what to do more, so 开发者_JAVA技巧any hints will be welcomed,

thx in advance.

EDIT: I also tried with no or single or double quotes as date.timezone = 'Europe/Berlin' but I still get a "no value" in the phpinfo.

EDIT2: Both phpinfo() and the below test script return that the date.timezone is empty (eg. no value) :

 date_default_timezone_set('America/Los_Angeles');
 $script_tz = date_default_timezone_get();
 $iniset = ini_get('date.timezone') ;
 if (strcmp($script_tz, $iniset)){
   echo "Script timezone ($script_tz) differs from ini-set timezone ($initset).";
 } else {
   echo "Script timezone ($script_tz) and ini-set timezone match.";
 }

EDIT3: hum, I guess I found sthg in the php.ini :

 Configuration File (php.ini) Path : /usr/local/php533/php.ini 
 Loaded Configuration File : VOID !

So I have to find the way to make sure Apache is looking for the right php.ini somehow...


I think you're missing the quotes:

date.timezone = "Europe/Berlin"

The value is a string according to: ini.date.timezone on PHP.net which must be wrapped in quotes.


Hope it can help others on debian's like distros :

SOLVED:
needed to tell Apache to load the wanted php.ini file

Context:
PHP loaded as an Apache module (eg DSO)

HOW in short :
shell ENV

PHP_INI_SCAN_DIR=/pathtophpini
export PHP_INI_SCAN_DIR

http.conf

# ...
# DSO Modules: PHP as an Apache module
SetEnv PHPRC /usr/pathtophpini
SetEnv PHP_INI_SCAN_DIR /usr/pathtophpini

LoadModule php5_module /pathtophpmod/libphp5.so
PHPINIDir /pathtophpini
# ...

Shell

/etc/init.d/apache2 restart   

Now just checking that the loaded configuration file php.ini is the right one either using the php-cli in commandline or phpinfo() :

/path/to/your/phpcli/bin/php -i | grep php.ini | tail -n2   
# which gives you the expected answer
Configuration File (php.ini) Path => /pathtophpini/php.ini
Additional .ini files parsed => /pathtophpini/php.ini

Some more documentation :
on that very particular point, provided there are very few docs on that subject, as this is a kind of shared responsability topic between apache and php matters :
on stackoverflow
on php manual
askapache

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜