10.14.06

Vi: Search and Replace

Posted in Linux, Miscellaneous at 9:58 pm by

Search (Wraped around at end of file):

Search STRING forward :   / STRING.
Search STRING backward:   ? STRING.

Repeat search:   n
Repeat search in opposite direction:  N  (SHIFT-n)

Replace: Same as with sed, Replace OLD with NEW:

First occurrence on current line:      :s/OLD/NEW

Globally (all) on current line:        :s/OLD/NEW/g

Between two lines #,#:                 :#,#s/OLD/NEW/g

Every occurrence in file:              :%s/OLD/NEW/g

10.10.06

Posted in Linux, Miscellaneous at 11:14 pm by

Getting awstats running with geoip

GeoIp C API

To start you‘ll need to install GeoIP C API. Download it :

wget http://www.maxmind.com/download/geoip/api/c/GeoIP.tar.gz 
 
Next thing is unzipping it and placing the directory where you want it.
I use midnight commander for this so just fire it up and copy it.
 
Starting midnight commander:
 
Mc
 
Go into the directory you just created by unzipping.
 
Do the following commands:
 
./configure
make
make check
make install
 
The GeoIP C API has been installed. Next we install the IP Perl Module.
 
When this fails and you are on a linux distro(debian taste) you might want to run:
apt-get update
apt-get upgrade
apt-get install gcc
apt-get install make
apt-get install texinfo
apt-get install libc6
apt-get install zlib1g-dev
 
 

GeoIP Perl API

Download Geo::IP Perl Module, use the command below but recplace THE_LAST_VERSION with the right tar.gz file

wget http://www.maxmind.com/download/geoip/api/perl/THE_LAST_VERSION

Next thing is unzipping it and placing the directory where you want it.
Go into the directory you just created by unzipping.

Now do the following commands. (if you have a problem with the make test see for instruction after the commands)

perl Makefile.PL
make
make test
make install
 

Only if you had problems

 
If you get a "libGeoIP.so.1: cannot open shared object No such file or
directory" error, add /usr/local/lib to /etc/ld.so.conf then run
/sbin/ldconfig /etc/ld.so.conf     
 
 
 

Awstats

Now you need to go to the config file of your website and alter the Plugin: GeoIP part.

Change /pathto/GeoIP.dat to where this database acctually is. You can quicly find it by

Doing a locate. Well quickly you’ll have to do a locate –u first of course which will take some time.

locate –u

locate GeoIP.dat

On my system it returns:

/usr/local/share/GeoIP/GeoIP.dat

Now I replace # LoadPlugin="geoip GEOIP_STANDARD /pathto/GeoIP.dat"

By

LoadPlugin=”geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat”

This is the section where to do it

 
# Plugin: GeoIP

# Perl modules required: Geo::IP or Geo::IP::PurePerl (from Maxmind)

# Country chart is built from an Internet IP-Country database.

# This plugin is useless for intranet only log files.

# Note: You must choose between using this plugin (need Perl Geo::IP module

# from Maxmind, database more up to date) or the GeoIPfree plugin (need

# Perl Geo::IPfree module, database less up to date).

# This plugin reduces AWStats speed of 8% !

#

#LoadPlugin="geoip GEOIP_STANDARD /pathto/GeoIP.dat"
 
Also make sure that DNSLookup look up is turned off.
 
DNSLookup=0
 

Congratulations you have now a awstats with a working geoip module.