PHP的错误500:时区数据库已损坏 – 这应该*永远不会发生

我有一个新的Ubuntu服务器16.04 amd64与Apache 2.4.18和PHP 7.0的安装。

我已经在/etc/apache2/apache2.conf中使用mod_envChrootDir / var / www chrooted Apache ,据我所知在这里是这个问题。 我想要做一个NexctCloud 11安装,但是一开始运行时会运行一个500错误。

Apache错误日志:

[Fri Mar 17 08:21:22.262901 2017] [:error] [pid 31480] [client 193.175.51.226:55749] PHP Notice: date_default_timezone_set(): Timezone ID 'UTC' is invalid in /html/sub.example.com/public_html/lib/base.php on line 637, referer: https://sub.example.com/ [Fri Mar 17 08:21:22.266581 2017] [:error] [pid 31480] [client 193.175.51.226:55749] PHP Warning: DateTime::createFromFormat(): Invalid date.timezone value 'Europe/Berlin', we selected the timezone 'UTC' for now. in /html/sub.example.com/public_html/lib/private/Log/File.php on line 85, referer: https://sub.example.com/ [Fri Mar 17 08:21:22.266610 2017] [:error] [pid 31480] [client 193.175.51.226:55749] PHP Fatal error: DateTime::createFromFormat(): Timezone database is corrupt - this should *never* happen! in /html/sub.example.com/public_html/lib/private/Log/File.php on line 85, referer: https://sub.example.com/ 

如果我停用Chroot,一切都很好,但我更喜欢其他解决scheme,我不必停用chroot。

我在网上find了一个build议: http : //ivanbayan.com/index.php/2013/06/26/how-to-fix-timezone-database-is-corrupt-this-should-never-happen/ which我试了(为我的php7定制),但它没有解决问题。 此外,我尝试了一些build议,从这里解决我的问题: PHP的启动:时区数据库已损坏

//编辑:这似乎不仅是NextCloud的问题。 这是一个在PHP中使用date()函数的问题。 以下脚本在相同的错误中产生:

 <?php date_default_timezone_set('Europe/Berlin'); echo date("l"); ?> 

解:

 mkdir -p /var/www/usr/lib/locale mkdir -p /var/www/usr/share/zoneinfo cd /var/www cp /etc/localtime etc/localtime cp /usr/share/zoneinfo/ usr/share/zoneinfo/ 

这解决了这个问题(有更多的错误与NectCloud和Chroot,例如我用相同的程序修复的语言环境)。