PHP命令行错误:时区数据库已损坏

时间:2013-12-23 12:03:36

标签: php date permissions timezone

我的date.php是 -

<?php
echo date('Y');

当我在我的登台机器上执行php -f date.php时,我收到错误 -

PHP Fatal error:  date(): Timezone database is corrupt - this should *never* happen! 
in /home/staging/test/date.php on line 2

但是当我在我的本地/ dev机器上执行相同的工作时。虽然在暂存和本地计算机上,/etc/localtime/usr/share/zoneinfo/上的权限都相同。

file /etc/localtime的输出在两台机器上都有所不同。

本地(php5.3.5)

/etc/localtime: timezone data, version 2, 4 gmt time flags, 4 std time flags, no leap seconds, 4 transition times, 4 abbreviation chars

暂存(php5.3.10)

/etc/localtime: timezone data, version 2, 1 gmt time flag, 1 std time flag, no leap seconds, no transition times, 1 abbreviation char

在尝试查找问题时,我发现了this link来自SO。我对接受的答案感到困惑。 我的apache用户没有执行脚本

似乎有什么问题?我该如何解决这个问题?

3 个答案:

答案 0 :(得分:1)

由于各种原因,PHP附带了自己的时区数据库 - 可以通过在编译时以不同方式配置软件来使用系统TZDB。

PHP timezonedb实现为C code(许多定义) - 因此您需要重新编译PHP才能使其正常工作。

如果您的PHP解释器未明确配置为使用操作系统timezoneDB,那么您确实需要调查可执行文件损坏的原因。

答案 1 :(得分:0)

Please check permission of your timezone files.It might have changed when you have  install some rpms. 
change the permission to 655
Also check following files:

/usr
/lib
/share
/etc

答案 2 :(得分:0)

我的问题是我正在chroot模式下运行php-fpm。我将其更改为在没有chroot的情况下运行,然后错误消失了。