禁用域的访问日志logging。 (使用CentOS和Apache)

我正在尝试禁用我的专用服务器上的域的访问日志超过10小时。 我在search时阅读了70多页。 我问在Parallel的论坛上,我以另一种方式问s​​tackoverflow ..我仍然无法禁用域的访问日志logging。

服务器configuration不是我的职业,我可能被认为是这个领域的许多人的新手。

最后一次,我尝试通过将CustomLog /dev/null plesklog到/var/www/vhosts/xxx.com/conf/vhost.conf来禁用它,然后运行/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=xxx.com ( source )。 但它没有工作。

请帮帮我。

你真的需要学习如何提出你的问题,不要再重复自己(你已经为同一个问题打开了几个post,每个post都有不同的细节)…

你的问题应该说:“如何禁用Plesk控制的Apache中的所有虚拟主机的访问日志?

从我读过的内容来看,没有简单的方法,因为Plesk每次修改内容时都会创build/重写所有apache .conf文件。

有人做了什么,是创build一个shell脚本,用每个虚拟主机的所有http.include文件中的“#CustomLog”replace“CustomLog”的所有实例,并将此脚本添加到crontab中,以便每15分钟运行一次。

看到他的线程: http : //forums.theplanet.com/lofiversion/index.php/t52435.html

然后,我会使用Perl进行就地replace,就像这样。 我的版本也只注释了CustomLog行,如果它是行上的第一个关键字,我做了这样httpd只重新加载(SIGHUP),而不是试图启动它,所以它是更好的:

 #!/bin/bash for FILE in /home/httpd/vhosts/* do perl -p -i -e "s/^[[:space:]]*CustomLog/#CustomLog/" "$FILE/conf/httpd.include" done service httpd reload exit 0 

确保这是以root身份运行的。

我认为我的解决scheme是不正确的答案禁用所有域的日志logging,但也许你喜欢它,因为它是一个简单的解决scheme;-)

我原来的工作是掩盖所有的IP地址,由于隐私问题。 我有两个解决scheme,这取决于您的Plesk版本。 这个解决scheme在apache2 CentOS和Debian上进行了testing。

我覆盖了“main”Apacheconfiguration文件中的“plesklog”指令。 '%h'格式被replace为固定的本地IP地址,Plesk空间和stream量计算将像以前一样工作。

在Debian squeeze / sid和Plesk 10.x上,更改configuration文件“/etc/apache2/apache2.conf”。 search行:'包括/etc/apache2/conf.d/'并覆盖'plesklog'variables(即%h => 127.0.0.2)。 重新启动apache2 …完成

 # # Hack to get rid of the IP Address in the log files, # plesklog HAVE TO defined AFTER the Plesk zz... Include! # Include /etc/apache2/conf.d/ <IfModule mod_logio.c> LogFormat "127.0.0.2 %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" plesklog </IfModule> <IfModule !mod_logio.c> LogFormat "127.0.0.3 %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" plesklog </IfModule> 

在Plesk 9.5.x的CentOS上,您可以将文件“/etc/httpd/conf.d/zz010_psa_httpd.conf”中的格式更改为想要的格式,参见上文。 这是可能的,因为Plesk 9不会像Plesk 10那样重新configuration其主configuration。

如果你不想logging,只需input一个减号或任何你想要的,即

 LogFormat "-" plesklog 

一切都必须以root身份完成,它将影响此服务器上的每个/所有plesk域;-)

要禁用特定虚拟主机的访问日志,您必须find相关的CustomLogconfiguration行,并在其前面加上#来将其变成注释。

 CustomLog logs/access_log plesklog 

 #CustomLog logs/access_log plesklog 

一旦你完成这个重新启动apache

 service httpd restart 

在你的例子中,要将你的日志传送到/ dev / null,你需要像这样定义CusomLog

 CustomLog "|/dev/null" plesklog 

pipe道| 一开始是重要的。