首页 » 网站建设 »

配置Apache多虚拟主机各自单独记录网站日志

2015年12月1日 / 65次阅读
APACHE

文章《配置Apache多虚拟主机各自单独记录网站日志》的特色图片

如果你像麦新杰一样,使用阿里云ECS主机,或者类似的VPS,在使用Apache作为服务器的时候,一般都需要配置多虚拟主机。只跑一个网站太浪费主机资源了,除非你的这个站流量很大。在多虚拟主机同时运行的情况下,还有一个配置比较重要,就是给各个虚拟主机配置单独记录网站日志的功能。本文介绍如何在Apache环境下配置多虚拟主机各自单独记录网站日志。

进行如下配置的前提是,你的多虚拟主机已经配置成功了。下面的配置实例,说明了如何给多个虚拟主机配置单独记录网站日志功能(配置文件为httpd-vhosts.conf):

# Virtual Hosts
#
# Required modules: mod_log_config

# 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.4/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 1093023102@qq.com
DocumentRoot "C:/maixj_sites/maixj.net"
ServerName maixj.net
ServerAlias www.maixj.net
ErrorLog "|bin/rotatelogs.exe -l ../../mysites/maixj.net/logs/error_%Y_%m_%d.log 86400"
CustomLog "|bin/rotatelogs.exe -l ../../mysites/maixj.net/logs/access_%Y_%m_%d.log 86400" combined
</VirtualHost>

<VirtualHost *:80>
ServerAdmin 1093023102@qq.com
DocumentRoot "C:/maixj_sites/wpchajian.cn"
ServerName wpchajian.cn
ServerAlias www.wpchajian.cn
ErrorLog "|bin/rotatelogs.exe -l ../../mysites/wpchajian.cn/logs/error_%Y_%m_%d.log 86400"
CustomLog "|bin/rotatelogs.exe -l ../../mysites/wpchajian.cn/logs/access_%Y_%m_%d.log 86400" combined
</VirtualHost>

 

请注意以上配置高亮部分。这个配置同时还实现了让网站每天生成新日志文件的功能

本文链接:http://www.maixj.net/wz/apache-log-9191
云上小悟 麦新杰(QQ:1093023102)

相关文章

评论是美德

无力满足评论实名制,评论对非实名注册用户关闭,有事QQ:1093023102.


前一篇:
后一篇:

栏目精选

云上小悟,麦新杰的独立博客

栏目


©Copyright 麦新杰 Since 2014 云上小悟独立博客版权所有 备案号:苏ICP备14045477号-1。云上小悟网站部分内容来源于网络,转载目的是为了整合信息,收藏学习,服务大家,有些转载内容也难以判断是否有侵权问题,如果侵犯了您的权益,请及时联系站长,我会立即删除。

网站二维码
go to top