我的apache2服务器写入虚拟主机访问日志没有问题,但没有写错误日志。
虚拟主机configuration如下:
<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
任何想法为什么错误日志无法显示?
看起来,自定义错误日志还没有可用的错误。
在rotatelogs --help这两个选项interessting:
-f Force opening of log on program start. -c Create log even if it is empty.
我在VirtualHost标签中的这个设置下在我的网站上testing了一台机器:
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.log出现,即使它是空的。