1. 打开apache的虚拟主机配置日志
[root@localhost ~]# vim /usr/local/httpd/conf/extra/httpd-vhosts.conf
# If you want to maintain multiple domains/hostnames on your
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/local/httpd/htdocs/discuz/"
ServerName www.discuz.com
ServerAlias discuz.com
ErrorLog "/usr/local/httpd/logs/error_log"
CustomLog "| /usr/local/httpd/bin/rotatelogs /usr/local/httpd/logs/access_%Y%m%d.log 86400 480" combined
</VirtualHost>
2.主要修改文件如下:
利用httpd自带的命令rotatelogs进行日志分割
CustomLog "| /usr/local/httpd/bin/rotatelogs /usr/local/httpd/logs/access_%Y%m%d.log 86400 480" combined
3. rotatelogs命令解析:
官方主页:http://httpd.apache.org/docs/2.4/programs/rotatelogs.html