简体   繁体   English

PHP-FPM 不写日志

[英]PHP-FPM doesn't write on the log

I have this php-fpm.conf我有这个 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

I don't understand why /home/vhosts/example.com/log/php-error.log is empty, I caused some errors like 10 / 0 (Zero division) etc etc, I see the error as output but the php-error.log still empty.我不明白为什么 /home/vhosts/example.com/log/php-error.log 是空的,我导致了一些错误,如 10 / 0(零除)等,我看到错误为 output 但 php- error.log 仍然为空。

I chrooted my vhost, but If i change我chroot了我的虚拟主机,但如果我改变

/home/vhosts/example.com/log/php-error.log /home/vhosts/example.com/log/php-error.log

to

/log/php-error.log /log/php-error.log

I get a really strange error, when I do "10 / 0"!当我执行“10 / 0”时,我遇到了一个非常奇怪的错误!

Fatal error: main(): Timezone database is corrupt - this should *never* happen! in /web/index.php on line 10 

From Debian's documentation:来自 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. 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.请注意,这要求 PHP 进程可以访问 /etc/localtime 和 /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."对于任何常规安装都应该是这种情况,但是在特定的安全环境中,当读取时区数据库是不可能的时,PHP 将给出“时区数据库已损坏 - 这永远不会发生”。 error.错误。

So you need to copy /etc/localtime file and /usr/share/zoneinfo directory to your chroot directory.所以你需要将 /etc/localtime 文件和 /usr/share/zoneinfo 目录复制到你的 chroot 目录。

You're not seeing the log entries because the log path you're specifying is the 'real path':您没有看到日志条目,因为您指定的日志路径是“真实路径”:

php_admin_value[error_log]          = /home/vhosts/example.com/log/php-error.log

Because you are chrooting you need to specify the 'chroot relative path':因为您正在 chroot,所以您需要指定“chroot 相对路径”:

php_admin_value[error_log]          = /log/php-error.log

This is because for the php-fpm worker /home/vhosts/example.com/ is really / due to the chrooting.这是因为对于 php-fpm worker /home/vhosts/example.com/ 是真的 / 由于 chrooting。

I haven't tested it but I suspect your session path might also be subject to this as well, so you'll need to make sure "chrooted /tmp" exists (really /home/vhosts/example.com/tmp) and is writable by the user you're using for that php-fpm pool.我还没有测试过,但我怀疑你的 session 路径也可能会受到这个影响,所以你需要确保“chrooted /tmp”存在(真的是/home/vhosts/example.com/tmp)并且是可由您用于该 php-fpm 池的用户写入。

I'm currently having similar issues that could be related to the listen.backlog setting.我目前遇到可能与 listen.backlog 设置相关的类似问题。 I've been finding different posts claiming that -1 can be wrongly interpreted.我一直在发现不同的帖子声称 -1 可能会被错误地解释。 I'm currently experimenting with setting listen.backlog to 0 or a high value.我目前正在尝试将 listen.backlog 设置为 0 或高值。 I'll see what the outcome is and keep you posted.我会看看结果是什么,并随时通知你。

Have you tried correcting the log path as follows?您是否尝试过如下更正日志路径? log/php-error.log (the leading slash makes it look for the /log folder which usually doesn't exist on a Linux system. log/php-error.log(前导斜杠使其查找 /log 文件夹,该文件夹通常在 Linux 系统上不存在。

Kind regards亲切的问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM