WEB STATISTICS ON CENTOS 5 (version 2)

yum install awstats

Optional: (To see what countries are visiting your website)

# yum install perl-Geo-IP

# yum install GeoIP-data

Prepare the configuration file:

# cd /etc/awstats

# mv awstats.model.conf awstats.model.bak # Keep a backup of the original

# mv awstats.localhost.localdomain.conf awstats.example.com.conf # Change it to your domain

Edit the configuration file:

# vi /etc/awstats/awstats.example.com.conf

In line 51: change LogFile=”/var/log/httpd/access_log” to the location of the access_log file you want to gather statistics.

Ex: LogFile=”/var/log/httpd/example.com-access_log”

In line 153: change SiteDomain=”localhost.localdomain” to SiteDomain=”example.com”

In line 168: change HostAliases=”localhost 127.0.0.1″ to HostAliases=”www.example.com”

In line 203: change DirData=”/var/www/awstats” to your docroot.

Ex: DirData=”/var/www/htdocs/example.com/awstats”

If you installed the Geo-IP plugins you need to enable it:

In line 1305 change #LoadPlugin=”geoip GEOIP_STANDARD /pathto/GeoIP.dat” to LoadPlugin=”geoip GEOIP_STANDARD /var/lib/GeoIP/GeoIP.dat”

Move the awstats directory to your docroot:
//uncessary, check http://shebangme.blogspot.com/2010/06/install-awstats-on-centos-5.html

# mv /var/www/awstats /var/www/htdocs/example.com

Change the permissions to the awstats directory:

# chown -R localuser:apache /var/www/htdocs/example.com/awstats

Edit the awstats.conf to setup the aliases and restrictions:

# vi /etc/httpd/conf.d/awstats.conf

Change the Alias, ScriptAlias and Directory location to where the awstats is in your docroot.

ex:

Alias /awstats/icon/ /var/www/htdocs/example.com/awstats/icon/

ScriptAlias /awstats/ /var/www/htdocs/example.com/awstats/

<Directory /var/www/htdocs/example.com/awstats/>

DirectoryIndex awstats.pl

Options ExecCGI

order deny,allow

deny from all

allow from 192.168.1. 66.80.199.111 # Allow access to awstate from the 192.168.1.0/24 subnet only

</Directory>

#Alias /css/ /var/www/awstats/css/

#Alias /js/ /var/www/awstats/js/

Reload Apache:

# service httpd reload

In case you don’t have the Options FollowSymLinks in httpd.conf, awstats will not work so you need to add it in the /etc/httpd/conf.d/awstats.conf above.

……..

Options ExecCGI

Options FollowSymLinks

……..

Update your statistics:

# cd /var/www/htdocs/example.com/awstats

# perl awstats.pl -config=example.com -update

If you see something like:

Create/Update database for config “/etc/awstats/awstats.example.com.conf” by AWStats version 6.9 (build 1.925)

From data in log file “/var/log/httpd/example.com-access_log”…

Phase 1 : First bypass old records, searching new record…

Direct access after last parsed record (after line 4)

Jumped lines in file: 4

Found 4 already parsed records.

Parsed lines in file: 13

Found 0 dropped records,

Found 0 corrupted records,

Found 0 old records,

Found 13 new qualified records.

Then everything went fine.

If you changed your logs from common to combined it might throw some errors when you update awstats so you need to clean the log file to have only the combined logs:

# cat /dev/null > /var/log/httpd/example.com-access_log

run the update again:

# perl awstats.pl -config=example.com -update

Update for config “/etc/awstats/awstats.example.com.conf”

With data in log file “”

Phase 1:

Seaching new records from beginning of log file

Phase 2:

Found 2389 new qualified records.

Navigate to http://example.com/awstats/awstats.pl

If the update time on the upper left hand corner is the same as the time you run the awstats.pl update and you can see the statistics, then everything works fine.

Setup the cron job (it will run hourly and redirect the output to /dev/null so it’s not going to send an email to root every hour) :

cd /etc/cron.hourly

echo “perl /var/www/htdocs/example.com/awstats/awstats.pl -config=example.com -update > /dev/null 2>&1″ > awstats.sh

chmod 755 awstats.sh

test the script:

./awstats.sh

Refresh your browser and if the update time changes then you are all set.

Enjoy the statistics on your website!

3 Replies to “WEB STATISTICS ON CENTOS 5 (version 2)”

  1. Heya¡­my very first comment on your site. ,I have been reading your blog for a while and thought I would completely pop in and drop a friendly note. . It is great stuff indeed. I also wanted to ask..is there a way to subscribe to your site via email?

Leave a Reply