在CentOS 6上部署Webalizer日志分析工具
sunkuohao 2012-10-25
Webalizer + CentOS 6
安装过程:
我们这里首先需要一个apache,作为webalizer的页面展示服务器
# yum -y install httpd
# yum -y install gd*
# yum -y install zlib*
# yum -y install font*
# yum install db4-devel
geoip软件下载:
http://www.findthatzip.com/search-41538008-hZIP/winrar-winzip-download-webalizer-geoip-2.1.10-13.tbz.htm
http://www.findthatzip.com/search-3066664-fZIP/winrar-winzip-download-webalizer-geoip-2.23.5.tbz.htm
# cd /home/jtian/softwares
# wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
# tar -zxf GeoIP.tar.gz
# cd GeoIP-1.4.8
# ./configure
# make && make install clean
# cd /home/jtian/softwares/GeoIP-1.4.8/data
# cp GeoIP.dat /usr/share/GeoIP
准备ip查询库:
# cd /home/jtian/softwares
# wget ftp://ftp.mrunix.net/pub/webalizer/webalizer-geodb-latest.tgz
# tar -zxf webalizer-geodb-latest.tgz
# cp GeoDB.dat /usr/share/GeoDB
准备国旗图片库
在webalizer的首页上下载国旗库
# mkdir /var/www/html/usage ; cd /var/www/html/usage
# wget ftp://ftp.mrunix.net/pub/webalizer/webalizer-flags.tgz
# tar -zxf webalizer-flags.tgz
# ll
总用量 188
-rw-r--r-- 1 root root 6607 9月 7 11:30 ctry_usage_201201.png
-rw-r--r-- 1 root root 3652 9月 7 11:30 ctry_usage_201209.png
-rw-r--r-- 1 root root 5992 9月 7 11:30 daily_usage_201201.png
-rw-r--r-- 1 root root 5687 9月 7 11:30 daily_usage_201209.png
drwxr-xr-x 2 root root 12288 9月 7 11:30 flags
-rw-r--r-- 1 root root 4316 9月 7 11:30 hourly_usage_201201.png
-rw-r--r-- 1 root root 3650 9月 7 11:30 hourly_usage_201209.png
-rw-r--r-- 1 root root 7879 9月 7 11:30 index.html
-rw-r--r-- 1 root root 74757 9月 7 11:30 usage_201201.html
-rw-r--r-- 1 root root 37979 9月 7 11:30 usage_201209.html
-rw-r--r-- 1 root root 5153 9月 7 11:30 usage.png
-rw-r--r-- 1 root root 2883 9月 7 11:30 webalizer.hist
//所以,我们的国旗库路径在/var/www/html/usage/flags
webalizer的下载地址: http://www.webalizer.org/download.html
# cd /home/jtian/softwares
# wget ftp://ftp.mrunix.net/pub/webalizer/webalizer-2.23-05-src.tgz
# tar -zxf webalizer-2.23-05-src.tgz
# cd webalizer-2.23-05/lang
# mv webalizer_lang.simplified_chinese webalizer_lang.simplified_chinese.bak
# iconv -f gb2312 -t utf-8 -s -c --verbose webalizer_lang.simplified_chinese.bak -o webalizer_lang.simplified_chinese 转换编码
webalizer_lang.simplified_chinese.bak:
# rm -rf webalizer_lang.simplified_chinese.bak
# cd ..
# vi graph.c
这里是在做汉化的基本过程,需要在最后加入下面的内容
void gdImageString(gdImagePtr im, gdFontPtr font, int x, int y, unsigned char *s, int color)
{
gdImageStringFT(im, 0 , color, "/usr/share/fonts/chinese/TrueType/STFANGSO.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/STFANGSO.TTF", 9 , -PI/2, x, y-9 , s);
}
# mkdir -p /usr/share/fonts/chinese/TrueType/
//从windows上上传一个字体文件到上面建立的目录下
开始正式编译软件:
# ./configure --prefix=/usr/local/webalizer --with-gd=/usr/bin --with-gdlib=/usr/lib --with-png --with-pnglib --with-geoip=/usr/local/lib --with-language=simplified_chinese --enable-geoip --with-geodb=/usr/share/GeoDB
# make && make install clean
安装完成后
# cd /usr/local/webalizer
# ll
total 12
drwxr-xr-x 2 root root 4096 Sep 6 13:54 bin
drwxr-xr-x 2 root root 4096 Sep 6 13:54 etc
drwxr-xr-x 3 root root 4096 Sep 6 13:54 share