我的 apache2 服务器可以毫无问题地写入 vhost 访问日志,但无法写入错误日志。vhost
配置如下:
<VirtualHost *:80>
ServerName sub.domain.com
Redirect permanent / https://sub.domain.com/
</VirtualHost>
<VirtualHost *:443>
ServerName sub.domain.com
ServerAdmin [email protected]
DocumentRoot /home/webadmin/web/www.domain.com/
<Directory /home/webadmin/web/www.domain.com/>
Order allow,deny
Allow from all
Require all granted
Allowoverride All
</Directory>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/domain.com.2017.crt
SSLCertificateKeyFile /etc/apache2/ssl/domain.com.2017.key
SSLCACertificateFile /etc/apache2/ssl/domain.com.2017.ca.crt
Header always set Strict-Transport-Security "max-age=15768000"
Customlog "|/usr/bin/rotatelogs /home/webadmin/logs/www.domain.com/ex%y%m%d.log 86400" combined
Errorlog "|/usr/bin/rotatelogs /home/webadmin/logs/www.domain.com/er%y%m%d.log 86400"
</VirtualHost>
apache2ctl -S
输出:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80 is a NameVirtualHost
default server othersub.domain.com (/etc/apache2/sites-enabled/othersub.domain.com.conf:1)
port 80 namevhost othersub.domain.com (/etc/apache2/sites-enabled/othersub.domain.com.conf:1)
port 80 namevhost sub.domain.com (/etc/apache2/sites-enabled/sub.domain.com.conf:1)
*:443 is a NameVirtualHost
default server othersub.domain.com (/etc/apache2/sites-enabled/othersub.domain.com.conf:7)
port 443 namevhost othersub.domain.com (/etc/apache2/sites-enabled/othersub.domain.com.conf:7)
port 443 namevhost sub.domain.com (/etc/apache2/sites-enabled/sub.domain.com.conf:7)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
知道为什么错误日志没有出现吗?
答案1
看起来,自定义错误日志中还没有可用的错误。
其中有rotatelogs --help
两个选项很有趣:
-f Force opening of log on program start.
-c Create log even if it is empty.
我尝试在我的网站上的测试机上使用此设置虚拟主机标签:
Customlog "|/usr/bin/rotatelogs -f /var/log/apache2/ex%y%m%d.log 86400" combined
Errorlog "|/usr/bin/rotatelogs -f /var/log/apache2/er%y%m%d.log 86400"
然后ex170925.日志尽管它是空的,但还是出现了。