apache安装目录 在phpinfo搜索Server Root /etc/apache2/
apache配置文件:httpd.conf或apache2.conf /etc/apache2/
.ini file 查看apache配置文件中
1直接写在apache配置 LoadModule mysql_auth_module modules/mod_auth_mysql.so
2 Include conf.d/*.conf
.so file 在apache配置文件中搜索modules /usr/lib/apache2/modules
www主目录:在phpinfo中搜索DOCUMENT_ROOT /var/www
------------------------------------------------------日志
222.180.75.170 - - [14/Nov/2010:00:00:25 +0800] "GET /up/mg/mp3/140/20100715211107387.mp3 HTTP/1.1" 206 250539 "http://mp3.sogou.com/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
60.213.133.42 - - [14/Nov/2010:00:00:51 +0800] "GET /include/ad.php?act=showggtop HTTP/1.1" 200 392 "http://www.51kxs.org/list.php?act=type&sec=25&page=1" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; GTB6; .NET CLR 2.0.50727)"
60.213.133.42 - - [14/Nov/2010:00:00:51 +0800] "GET /include/ad.php?act=showgglistright HTTP/1.1" 200 213 "http://www.51kxs.org/list.php?act=type&sec=25&page=1" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; GTB6; .NET CLR 2.0.50727)"
ErrorLog logs/test.***.com-error_log
CustomLog logs/test.***.com-access_log common #common格式
CustomLog /var/log/apache2/access.log combined #combined格式
日志格式默认的是common
日志的生成格式可以定制的,需要在配置文件中定义
LogFormat "%h %l %u %t \"%r\" %>s %b" common
启动APACHE的用户
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
编辑httpd.conf 设置如下:
<FilesMatch "\.(ico|gif|jpg|png|bmp|swf)">
SetEnv IMAG 1
</FilesMatch>
CustomLog logs/access_log combined env=!IMAG
这样记录文件access_log就不会记录ico|gif|jpg|png|bmp|swf的访问记录,同样也可以加上css|js才过滤css和js文件,效果很好.
----------------------------------------apache 日志的cronolog轮循和webalizer 合并统计
wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
tar xzvf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
2.编译
./configure
make
make install
3. 修改Apache的配置文件httpd.conf,加入以下代码
CustomLog "|/usr/local/sbin/cronolog /var/log/httpd/%Y_%m_%d.access.log" combined
======================shell
realdate=`date +%Y-%m-%d`
echo $realdate
cat /var/log/httpd/$(date +%Y_%m_%d).access.log |cut -d \" -f1,2,3,4 |awk '{if($4~"500")print $8}' |awk '$1!~/^.-/' |sort|uniq -c |sort -rn > /tmp/tmp
realdate=`date -d "yesterday" +"%Y-%m-%d"`
echo $realdate
cat /var/log/httpd/$(date -d "yesterday" +"%Y_%m_%d").access.log |cut -d \" -f1,2,3,4 |awk '{if($4~"500")print $8}' |awk '$1!~/^.-/' |sort|uniq -c |sort -rn > /tmp/tmp
cat /var/log/httpd/$(date +%Y_%m_%d).access.log |awk '{if($4~"404")print $8,$10}' |sort |uniq -c|sort -rn > /tmp/tmp2
cat /var/log/httpd/$(date +%Y_%m_%d).access.log |awk '$5 > 3' |awk '{print $8}' |sort |uniq -c |sort -rn > /tmp/tmp3
head -n 100 /tmp/tmp2 >> web404_log