我已经有了一个任务来理解为什么运行apache 2.2.3的2个CentOS web服务器在特定的场合下经历了非常高的负载。 我检查的第一件事是/var/log/messages但后来我意识到rsyslog由于某种原因被closures,所以我开始使用chkconfig打开它。 然后,我想检查Apache错误和访问日志,所以我浏览到/var/log/httpd但发现文件夹是空的。 我检查了/etc/httpd/conf/httpd.conf ,看到这些行:
ErrorLog logs/error_log CustomLog logs/access_log combined
据我所知,它指的是/var/log/httpd/但正如之前所说的那个文件夹是空的。 在写这个问题时,我已经在服务器上查找了httpd版本,运行httpd -v ,这就是我得到的回应:
[root@domU-IP httpd]# httpd -v Server version: Apache/2.2.3 Server built: May 4 2011 06:51:15 Unable to open logs
我的问题是:
1. What could cause the logs to disappear? (It is possible they were never created in the first place) 2. How can I recreate the logs and make sure data is written to them? 3. Which permissions should be set on `/var/log/httpd`? (current permissions are: drwx------ 2 root root)
提前致谢
当Apacheconfiguration中的path引用不是绝对path(即,不以/开始)时,它们与ServerRoot指令中设置的目录相关。 ServerRoot一个通用默认是/etc/httpd使/etc/httpd/logs你的日志目录。
大多数打包的Apache版本都会创build一个从/etc/httpd/logs到/var/log/httpd的符号链接。 / etc / httpd中的实际目录缺失(或根文件系统已满),或者您的设置中可能缺less符号链接。
Apache由root启动,并在删除权限之前以根用户身份打开日志文件,以便/ var / log / httpd上的这些目录权限看起来正确。
我的问题是,访问日志没有Log指令。 我按照这里的说明https://ubuntuforums.org/showthread.php?t=1704686其中基本上说:
在Ubuntu上,你应该有一个名为/etc/apache2/conf.d/other-vhosts-access-log的文件,内容如下:
# Define an access log for VirtualHosts that don't define their own logfile CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log vhost_combined
我错过了这个,这就是为什么我没有得到日志。