gpt4 book ai didi

php - 禁用 apache2 日志

转载 作者:行者123 更新时间:2023-12-04 14:03:02 26 4
gpt4 key购买 nike

我的服务器上只有 32GB 的空间,日志很快就用完了这个空间。所以我想禁用日志。

我想我找到了在哪里做,但由于我在服务器方面完全是个菜鸟,所以我不想在不确定它们不会使服务器崩溃的情况下开始更改。

在 etc/apache2/apache2.conf 中,我发现了这个:

    #
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

在 etc/apache2/conf.d/other-vhost-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

我需要做什么来禁用日志?

提前致谢

最佳答案

如果您真的想禁用日志,则必须注释掉 Apache 配置文件中的所有 ErrorLogCustomLog 指令。在 Debian 上,这些将位于 /etc/apache2/httpd.conf/etc/apache2/apache2.conf(基本配置),然后是 /etc/apache2/sites-available/*(特定的虚拟主机配置)。

您可以通过在它们前面添加“#”字符来将它们注释掉。

更改完成后,运行/etc/init.d/apache2 restart以使更改生效。

IMO,一个更好的解决方案——因为日志通常非常方便——是按照 Sergey 上面的建议安装日志轮换。在 Debian 中,运行这个:

 sudo apt-get install logrotate

logrotate 将在其默认配置中每天拆分日志并压缩旧日志,从而在保留日志本身的同时节省大量磁盘空间。

关于php - 禁用 apache2 日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10794612/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com