我使用的Linux系統是CentOS 5.5,有些系統服務版本比較低或者沒有,需要手動去安裝,例如實驗ntop依賴Python2.6以上的版本,但系統自帶的版本則是2.4。
CentOS yum 升級Python2.6 到 2.7 http://www.linuxidc.com/Linux/2014-07/104555.htm
在Red Hat Enterprise Linux 5.3安裝NTOP http://www.linuxidc.com/Linux/2011-07/38130.htm
使用yum快速安裝ntop的依賴包:
$ yum install libpcap libpcap-devel libtool linpng gdbm libxml2-devel gdbm-devel svn pango-devel pango subversion GeoIP GeoIP-devel
如果不安裝svn和subversion,在編譯的安裝的時候回報以下的錯誤:
You must have svn/subversion installed to compile autogen.sh.
Download the appropriate package for your distribution, or get the
source from http://subversion.tigris.org
$ tar zxf ntop-5.0.1.tar.gz
$ cd ntop-5.0.1
$ ./autogen.sh --with-tcpwrap
第一個錯誤:
configure: error: Unable to find RRD at /usr/local: please use --with-rrd-home=DIR
解決方法:
$wget http://down1.chinaunix.net/distfiles/rrdtool-1.3.5.tar.gz
$tar zxf rrdtool-1.3.5.tar.gz
$cd rrdtool-1.3.5
$./confogure --prefix=/usr/local/rrdtool
$make && make install
$ ./autogen.sh --prefix=/usr/local/ntop --with-tcpwrap --with-rrd-home=/usr/share/rrdtool/
第二個錯誤:
checking for python-config... no
>>>> Unable to locate python-config: using workaround <<<<
checking for python... python
checking Checking python version... Old python installed
Please install python 2.6 or newer.
解決方法:
#wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
#tar zxvf Python-2.7.3.tgz
#cd Python-2.7.3
$ cd Python-2.7.3
$ ./configure --prefix=/usr/local/python27
$mv /usr/bin/python /usr/bin/python.old
$ ln -s /usr/local/python27/bin/python /usr/bin/
$ python
Python 2.7.3 (default, Oct 9 2014, 15:06:43)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-55)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> ( ctrl+d )=退出
安裝完以後會發現yum不能使用,因為yum需要依賴於/usr/bin/python運行,所以,要做一下修改。
$vi /usr/bin/yum 把#!/usr/bin/python改為#!/usr/bin/python.old
第三個錯誤:
Removing dups and misplaced entries from LIBS and INCS...
checking for GeoIP_record_by_ipnum in -lGeoIP... no
checking for GeoIP_name_by_ipnum_v6 in -lGeoIP... no
Please install GeoIP (http://www.maxmind.com/)
解決方法:
明明我在開始的時候就已經通過yum方式安裝了GeoIP GeoIP-devel,為什麼還報這樣的錯呢?在這裡糾結的好久,最後在網上找到的解決方法。
$ wget http://www.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
$ tar zxf GeoIP.tar.gz
$ cd GeoIP-1.4.8/
$ ./configure && make && make install
$wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
$tar zxf GeoIP.tar.gz
$cd GeoIP-1.3.2
$ python setup.py build
$ python setup.py install
最後就應該可以編譯安裝了。
[root@localhost rrdtool-1.3.5]# ./autogen.sh --prefix=/usr/local/ntop --with-tcpwrap --with-rrd-home=/usr/share/rrdtool/
[root@localhost rrdtool-1.3.5]# make $$ make install
$ groupadd ntop
$useradd -M -s /sbin/nologin -g ntop ntop
$ chown -R ntop.ntop /usr/local/ntop/share/ntop
$ chown -R ntop.ntop /usr/local/ntop/var/ntop/
$ chown -R ntop.ntop /usr/local/ntop/lib/
配置ntop的管理員密碼:
$ntop -A
授權外部iP地址通過tcp-wrappers
$echo 'ntop 192.168.1.114' >> /etc/hosts.allow
拒絕外部ip地址:
$echo 'ntop:ALL' >> /etc/hosts.deny
啟動ntop:
$ cd /usr/local/ntop/bin
$./ntop
通過浏覽器訪問:http://ip:3000
更多CentOS相關信息見CentOS 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=14