错误未写入Apache错误日志

use*_*981 3 php apache error-logging

我遇到了一些Apache Web服务器错误日志的问题。

我的计算机上有一个虚拟托管的网站scotthermmann.loc。在我手动清除错误日志后,使用

sudo cat /dev/null > scotthermmann.loc-error_log
Run Code Online (Sandbox Code Playgroud)

或者通过在emacs中打开文件并删除所有内容,错误将不再记录到文件中。我试过使用

sudo apachectl restart
Run Code Online (Sandbox Code Playgroud)

解决问题,但不能解决。注销并重新登录也无法解决。解决问题的方法是重新启动计算机,但是每次清除错误日志后,我都不想这样做。

我托管的每个网站都并非如此。我有另一个网站nudefootfool.loc。清除错误日志后,我没有任何问题。

两个虚拟站点在httpd-vhosts.conf文件中的设置基本相同。对于scottherrmann.loc:

<VirtualHost *:80>
    DocumentRoot "/Users/dan/Sites/scottherrmann.com"
    ServerName scottherrmann.loc
    ServerAlias www.scottherrmann.loc
    ErrorLog "/private/var/log/apache2/scottherrmann.loc-error_log"
    CustomLog "/private/var/log/apache2/scottherrmann.loc-access_log"

    <Directory "/Users/dan/Sites/scottherrmann.com">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order Allow,Deny
        Allow from all 
    </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

而对于footfootfool.loc:

<VirtualHost *:80>
    DocumentRoot "/Users/dan/Sites/barefootfool.com"
    ServerName barefootfool.loc
    ServerAlias www.barefootfool.loc
    ErrorLog "/private/var/log/apache2/barefootfool.loc-error_log"
    CustomLog "/private/var/log/apache2/barefootfool.loc-access_log"

    <Directory "/Users/dan/Sites/barefootfool.com">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order Allow,Deny
        Allow from all 
    </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

有谁知道是什么原因引起的问题?

zza*_*per 5

我刚遇到这个问题是因为我不明智地删除了/ var / log / httpd / error_log文件,然后触摸了一个新的日志文件。

service httpd restart
Run Code Online (Sandbox Code Playgroud)

解决了问题。下次我将截断error_log

:>error_log
Run Code Online (Sandbox Code Playgroud)

  • 对于Ubuntu,这将是`service apache2 restart`。 (2认同)

Jor*_*pos 0

可能是因为您使用该用户运行 tomcat apachectl,当您使用该命令清除日志文件时,sudo cat /dev/null > scotthermmann.loc-error_log执行该命令的用户将获得该文件的所有权,然后该用户apachectl无法再在该文件上写入。尝试运行清理命令,如下所示:

sudo apachectl cat /dev/null > scotthermmann.loc-error_log
Run Code Online (Sandbox Code Playgroud)