Apache-2.4

PHP 錯誤 500:時區數據庫已損壞 - 這應該永遠不會發生

  • March 24, 2017

我全新安裝了帶有 apache 2.4.18 和 php 7.0 的 Ubuntu Server 16.04 amd64。

我已經 在*/etc/apache2/apache2.conf中使用**mod_env*和 ChrootDir /var/www對 Apache 進行了 chroot ,據我所知,這就是問題所在。我想做一個 NexctCloud 11 安裝,但在第一次執行時遇到 500 錯誤。

阿帕奇錯誤日誌:

[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,一切都很好,但我更喜歡其他解決方案,我不必停用 chroot。

我在網上找到了一個建議:http : //ivanbayan.com/index.php/2013/06/26/how-to-fix-timezone-database-is-corrupt-this-should-never-happen/我已經嘗試過(為我的 php7 定制),但它沒有解決問題。此外,我從這裡嘗試了一些建議,但沒有解決我的問題:PHP Startup: Timezone database is corrupt

//編輯:似乎這不僅是 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 存在更多錯誤,例如我用相同程序修復的語言環境)。

引用自:https://serverfault.com/questions/839384