Webalizer中文安装解析IP配置

之前安装的都是英文的,现在替换成中文的,并且新增ip位置解析
 参考地址 : http://haolulu.blog.51cto.com/3164472/630894

1.安装webalizer所需的软件包(需要用到相关的jpeg,png,zlib库)
  yum -y install gd-devel.i*
2. 安装GeoIP 
2.1 下载
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
2.2 解压
    tar -zxmf GeoIP.tar.gz
2.3 进入目录
    cd GeoIP-1.4.8
  2.4 编译 安装
     make && make install
  2.5 安装完成后,会在/usr/local/share/GeoIP/下生成一个GeoIP.dat文件  
3.下载Webalizer的源码包(官网http://www.webalizer.org/)
  3.1 解压
     tar -zxmf webalizer-2.23-08-src.tgz
  3.2 进入目录
     cd webalizer-2.23-08
  3.3 进入lang目录
找到 webalizer_lang.simplified_chinese  将文件格式转化为utf-8(我用的UltraEdit)
    [root@**** lang]# file webalizer_lang.chinese
    webalizer_lang.chinese: ASCII C program text
    [root@**** lang]# file webalizer_lang.simplified_chinese
    webalizer_lang.simplified_chinese: UTF-8 Unicode English text
  3.4 找一个中文字体,传到服务器上
地址 /usr/share/fonts
(我从win系统中扣得一个中文字体上传到这个目录的)
3.5 跳回到webalizer-2.23-08文件目录
     cd ..
  3.6 修改这个文件graphs.c
vi graphs.c
在文件最后加入(这里会出现编码或者全角……错误,会编译不过)
void gdImageString(gdImagePtr im, gdFontPtr font, int x, int y, unsigned char *s, int color)
{
gdImageStringFT(im, 0 , color, "/usr/share/fonts/simfang.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/simfang.ttf", 9 , -PI/2, x, y-9 , s);
}
       需要注意 /usr/share/fonts/simfang.ttf 是你自己上传的中文字体 绝对位置
  3.7 编译webzlizer
     ./configure --with-language=simplified_chinese
--enable-geoip ##启用geoip支持 --with-geoip=/usr/local/include ##geoip路径 --with-geoiplib=/usr/local/lib ##geoiplib库路径 make
     将libGeoIP复制到/usr/lib下,要不然启动服务会报错。
     cp -d -p /usr/local/lib/libGeoIP* /usr/lib/
  3.8 安装(两种,因情况而定)
1. 升级替换原来的
在目录下有一个 webalizer 替换你原来安装好 的目录下的webalizer二进制文件
        cp webalizer /usr/bin/
      2. 安装
        make install
         默认安装在 /usr/local/bin/webalizer(可以在安装的时候指定安装位置 --prefix=)
4. 运行webalizer
4.1 配置webalizer.conf文件
默认读取/etc/webalizer.conf
      ##nginx access.log 目录 (可以使压缩文件)
      LogFile         /usr/local/nginx/logs/access.log
      ##web访问目录,日志生成目录
      OutputDir     /usr/local/nginx/html
      Incremental     yes
##数据保存目录
IncrementalName /var/lib/webalizer/webalizer.current
HostName       统计的名称(默认是主机名)
#GeoDB 是官网下的
#
Latest Webalizer GeoDB database. Get this if you want to use the native Geolocation services provided by The Webalizer. Install instructions are included in the package.
GeoDB           yes
GeoDBDatabase   /usr/share/GeoDB/GeoDB.dat
      GeoIP           yes
GeoIPDatabase   /usr/local/share/GeoIP/GeoIP.dat
#官网下载 国家国旗图片
#
Country flag graphics for display in generated reports. Based on the country flag graphics found at flags.blogpotato.de with some additional images for geolocation support
CountryGraph    yes
CountryFlags    yes
#flags文件位置 相对于
OutputDir目录
FlagDir flags
   4.2 运行
      /usr/local/bin/webalizer

显示

       Webalizer V2.23-08 (Linux 2.6.32-358.6.2.el6.x86_64 x86_64) Simplified Chinese
       使用日志文件 /usr/local/nginx/logs/access.log (clf)
       Using GeoIP Country Edition (/usr/local/share/GeoIP/GeoIP.dat)
       输出结果到 /usr/local/nginx/html
       产生报表的主机名是 '*****-****-services'
       正在读取历史信息文件... localhost
       正在读取上次运行的数据... /usr/local/nginx/logs/webalizer.current
       正在保存当前运行的数据... [08/07/2014 15:39:10]
       正在生成报表 ---- 为 八月 2014
       正在保存历史信息文件...
       正在生成综合报表
       57853 条记录 共用时 1 秒, 57853/sec

       
4.3 定时运行
      crontab -e
0 0 * * * /usr/local/bin/webalizer & (每天生成一次日志)
5. 遇到的错误
5.1 make: Nothing to be done for `all'.
解决 make clean
5.2 /usr/local/bin/webalizer: error while loading shared libraries: libGeoIP.so.1: cannot open shared object file: No such file or directory
解决 运行ldconfig,以更新/etc/ld.so.cache文件
5.3 configure: error: gd library not found.. please install libgd
yum -y install gd gd-devel
5.4 在国外的两台服务器上搭建好了 运行总是卡在 没有历史信息文件... 一直不执行
make uninstall 卸载了之后,用 yum install webalizer 安装的 就可以,只是是英文
6. 图片


   

    

posted on 2014-08-07 15:27  Love I Smile  阅读(1917)  评论(0编辑  收藏  举报