我有这个 php-fpm.conf
[example.com]
listen = 127.0.0.1:9001
listen.owner = example.com
listen.group = example.com
listen.mode = 0660
listen.backlog = -1
user = example.com
group = example.com
pm = dynamic
pm.max_requests = 0
pm.max_children = 2
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1
chroot = /home/vhosts/example.com/
request_terminate_timeout = 2
request_slowlog_timeout = 1
slowlog = /home/vhosts/example.com/log/php-slow.log
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
php_flag[display_errors] = on
php_admin_value[session.save_path] = /tmp
php_admin_value[error_log] = /home/vhosts/example.com/log/php-error.log
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 100M
php_value[max_execution_time] = 20
我不明白为什么/home/vhosts/example.com/log/php-error.log 是空的,我导致了一些错误,例如 10/0(零除法)等,我看到错误作为输出,但是php-error.log 仍然为空。
我chroot了我的虚拟主机,但是如果我改变了
/home/vhosts/example.com/log/php-error.log
至
/log/php-error.log
当我执行“10/0”时,我收到一个非常奇怪的错误!
Fatal error: main(): Timezone database is corrupt - this should *never* happen! in /web/index.php on line 10
最佳答案
来自 Debian 的文档:
Timezone data from system timezone database
Debian PHP has been patched to use of the system wide timezone database from the tzdata package, making sure any updates there are automatically used by PHP aswell.
Note that this requires that the PHP process has access to /etc/localtime and /usr/share/zoneinfo. For any regular installation this should be the case, but in specific secured environments when reading the timezone database is impossible PHP will give a "Timezone database is corrupt - this should never happen!" error.
因此您需要将/etc/localtime 文件和/usr/share/zoneinfo 目录复制到您的 chroot 目录。
关于PHP-FPM 不写入日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5862453/