php5.3.3 date.timezone 再次 php.ini 指令未考虑在内 [英] php5.3.3 date.timezone again php.ini directive not taken into account

查看:22
本文介绍了php5.3.3 date.timezone 再次 php.ini 指令未考虑在内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

系统:Debian Lenny/Apache 2.2/php5.3.3 源码编译

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

我正在为 php.ini 中的 date.timezone 苦苦挣扎.

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

我可以在 php 源代码中定义 TZ,但我想在 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 代码:好的

date_default_timezone_set('Europe/Berlin');

php.ini : 如果不在源代码中设置,则不考虑

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

date.timezone = 'Europe/Berlin'

我还检查了我修改了正确的 php.ini 文件并干扰了一些 php.default.ini 文件.
我在 apache 配置文件中检查了是否会有干扰的 TZ env 数据,但没有.

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 any hints will be welcomed,

提前谢谢.

我也尝试使用无引号或单引号或双引号作为 date.timezone = 'Europe/Berlin' 但我仍然在 phpinfo 中得到无价值".

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.

phpinfo() 和下面的测试脚本都返回 date.timezone 为空(例如,没有值):

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:嗯,我想我在 php.ini 中找到了一些东西:

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 !

所以我必须想办法确保 Apache 以某种方式寻找正确的 php.ini...

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

推荐答案

希望它可以帮助其他类似 debian 的发行版:

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

已解决:
需要告诉 Apache 加载想要的 php.ini 文件

背景:
PHP 作为 Apache 模块加载(例如 DSO)

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

简而言之:
外壳环境

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
# ...

外壳

/etc/init.d/apache2 restart   

现在只需使用命令行中的 php-cli 或 phpinfo() 检查加载的配置文件 php.ini 是否正确:

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

更多文档:
在那个非常特殊的点上,只要关于该主题的文档很少,因为这是 apache 和 php 之间的一种共同责任主题:
在stackoverflow上
关于 php 手册
askapache

这篇关于php5.3.3 date.timezone 再次 php.ini 指令未考虑在内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆