在centos6上部署webalizer日誌分析工具

 

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軟件下載: 
# cd /home/jtian/softwares
# 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
# tar -zxf webalizer-geodb-latest.tgz
# cp GeoDB.dat /usr/share/GeoDB
 
準備國旗圖片庫
在webalizer的首頁上下載國旗庫
# mkdir /var/www/html/usage ; cd /var/www/html/usage
# 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
# 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
 
基本環境配置:
# mkdir /var/www/html/usage
//準備頁面所在的目錄地址
# cd /usr/local/webalizer/etc
# cp webalizer.conf.sample webalizer.conf
# vi webalizer.conf
//需要注意的是,這裏的flags要用相對路徑來表示,否則國旗圖案將不能夠正常顯示
 
LogFile /etc/httpd/logs/access_log
OutputDir /var/www/html/usage
PageType htm*
PageType cgi
GeoDB yes
GeoDBDatabase /usr/share/GeoDB
GeoIP yes
GeoIPDatabase /usr/share/GeoIP
CountryGraph yes
CountryFlags yes
FlagDir flags
HideURL *.gif
HideURL *.GIF
HideURL *.jpg
HideURL *.JPG
HideURL *.png
HideURL *.PNG
HideURL *.ra
# cd /etc/ld.so.conf.d
# vi webalizer.conf
/usr/local/lib/
# ldconfig
# vi /etc/httpd/conf/httpd.conf
DocumentRoot "/var/www/html/usage"
<Directory "/var/www/html/usage">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
AuthName "Webalizer Access"
AuthType Basic
AuthUserFile /etc/httpd/conf/htpasswd.users
Require valid-user
</Directory>
 
# htpasswd -c /etc/httpd/conf/htpasswd.users webalizer
New password: 
Re-type new password: 
Adding password for user webalizer
# service httpd restart
 
手動運行一下webalizer:
# /usr/local/webalizer/bin/webalizer -c /usr/local/webalizer/etc/webalizer.conf
Webalizer V2.23-05 (Linux 2.6.32-220.el6.x86_64 x86_64) Simplified Chinese
使用日誌文件 /etc/httpd/logs/access_log (clf)
輸出結果到 /var/www/html/usage
產生報表的主機名是 'www.lingling.com'
沒有找到歷史信息文件...
正在生成報表 ---- 爲 九月 2012
正在保存歷史信息文件...
正在生成綜合報表
76 條記錄 共用時 1 秒, 76/sec
//可見正常的完成了日誌的發佈更新工作
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章