Piwik 使用GeoIP 以及优化(一)

接上篇文章,开始给我的大部分网站使用piwik,但是使用piwik 首先需要的就是enable GeoIP

  1. GeoIP Module for Piwik

         Piwik 有四种方式来使用GeoIP, 分别是default, GeoIP(PHP), GeoIP(PECL), GeoIP(http or nginx)

        在高流量的网站,GeoIP PHP 就会显得速度慢很多,因此这里 GeoIP PECL 成为了piwik 的首选

      在piwik 的官方文档上有在ubuntu/debian 上安装pecl geoip 的办法,因此这里不再多说. 这篇文章主要说说如何安装GeoIP PECL 在RHEL系列的OS 上

      以CentOS为例,首先确保你的系统安装了PECL,如果没有的话就先google 一下安装PECL

     然后以root 执行下列命令

pecl install geoip

  然后有很大的可能性你会得到下面的error:

shtool at '/tmp/pear/temp/geoip/build/shtool' does not exist or is not executable.

  出现这个error 的原因在于/tmp 这个目录不允许执行可执行文件

  解决办法也很简单,就是更改pecl 的默认tmp 目录,比如改为/root/tmp

mkdir /root/tmp 
 pecl config-set temp_dir /root/tmp
 or
 pear config-set temp_dir /root/tmp

pecl config-set这个命令经常会出问题,因此建议使用pear config-set这个命令

更改完pecl 的tmp 默认目录以后,就可以顺利的执行pecl install geoip的命令了

安装完毕后,还剩下最后一件事: 配置php.ini, 添加geoip extension 和 目录

用你喜欢的编辑器,无论是是vi, vim 还是nano,编辑php.ini,添加如下代码:

[PHP]
 ;AFTER THE PHP SECTION NOT BEFORE
 extension=geoip.so

 

[gd] 
;AFTER THE gd SECTION NOT BEFORE 
geoip.custom_directory=/full/linux/path/to/piwik/misc

注意当使用pecl install geoip 的时候, extension=geoip.so 一般会自动添加到php.ini配置文件中,在这里你需要确定下

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.