安装webalizer解析apache日志(常规安装)

假定系统是centos

首先下载
ftp://ftp.mrunix.net/pub/webalizer/webalizer-2.23-05-src.tgz

然后,
yum install gd
yum install gd-devel

tar zxvf webalizer-2.23-05-src.tgz
cd webalizer-2.23-05
./configure --with-language=simplified_chinese
make
make install

cp /usr/local/etc/webalizer.conf.sample /etc/webalizer.conf
vim /etc/webalizer.conf

============================
在配置最后加上
LogFile        /home/apache_log/combined # 填写apache的日志文件,见下

LogType clf

OutputDir      网站文档根目录/logs
# 把“网站文档根目录”换成真实路径
# 要求logs这个目录事先创建好,并且可以任意写入。

Incremental     yes
速度快一些
============================
httpd.conf

在虚拟机virtualhost的块里面,
  SetEnvIfNoCase Request_URI "(\.css|\.js|\.ico|\.gif|\.png|\.jpe?g|\.swf|\.swc)" dontlog
  CustomLog "/home/apache_log/combined" combined env=!dontlog
  <Directory /文档根目录/logs>
         AddDefaultCharset gb2312
  </Directory>
====================================================
现在,每当执行
/usr/local/bin/webalizer -c /etc/webalizer.conf
时,会自动往logs这个目录加一些html和图片,只需在浏览器输入
http://域名/logs/index.html
就会看到统计结果。

为了自动化,编辑
vim  /etc/crontab
加入
0 1 * * * root /usr/local/bin/webalizer -c /etc/webalizer.conf
然后保存
再执行
/etc/init.d/crond restart

================

void gdImageString(gdImagePtr im, gdFontPtr font, int x, int y, unsigned char *s, int color){
  gdImageStringFT(im, 0, color, "/usr/share/fonts/chinese/TrueType/ukai.ttf", 9 , 0.0, x, y+9, s);
}

void gdImageStringUp(gdImagePtr im, gdFontPtr font, int x, int y, unsigned char *s, int color){
  gdImageStringFT(im, 0 , color, "/usr/share/fonts/chinese/TrueType/ukai.ttf", 9 , -PI/2, x, y-9 , s);
}



你可能感兴趣的:(apache)