www.linuxexpert.ro

Tutorials

  • Home
  • BGP Tutorials
    • Remove private AS
  • cPanel Tutorials
    • Install ImageMagick on cPanel
    • Install Softaculous
  • Linux Tutorials
    • Auto-reboot Linux after kernel panic
    • Building a firewall with Iptables
    • Change array RAID 1 disk order
    • Configure ntfs-3g on Linux Slackware
    • DHCP Option Codes
    • DansGuardian with Squid and ClamAV
    • Fetchmail for Gmail accounts
    • Install Zend & APC PHP Optimizers
    • Install Atheros AR242x PCI Express Adapter
    • Install awstats with DirectAdmin
    • Install DBD::mysql via CPAN shell
    • Install DjbDNS on Ubuntu
    • Installing fail2ban on Centos 5
    • Install GoDaddy SSL Certificate
    • Install i386 packages under x86_64
    • Install Linux via USB flashdrive
    • Install ModSecurity2 on Apache2.0.x
    • Install Nginx on CentOS
    • Install webalizer with ispconfig
    • Install intel A/B/G/N wireless on linux
    • Kernel Upgrade
    • Mobile phone access via bluetooth
    • Optimize MySQL
    • Optimize Qmail
    • Optimize server load
    • Optimize and Tune Apache for performance
    • Optimize and Tune Nginx for performance
    • Perfect Mailserver on Debian
    • Pidgin "Now Playing" Status Message
    • PHP hardening
    • PHP hardening with Suhosin
    • PHP5 Support allong with PHP4
    • Previewing your site before making DNS changes
    • Proxy Auto Configuration
    • PXE boot install rescue
    • Setup awstats on CentOS
    • Setup EC2 Amazon L2TP IPSec VPN
    • Setup email piping with Qmail
    • Setup Exim with DKIM
    • Setup Exim smart relay with cPanel
    • Setup OpenVPN
    • Setup postfix on nonstandard port
    • Setup SS5 Socks Proxy
    • Setup vsftp with no shell access
    • Sendmail smart relay with gmail auth
    • Squid proxy NCSA authentication
    • Tcpdump filters
    • Upgrade PHP to 5.3 in Plesk 10
    • Useful regular expressions
    • X with [SiS] 771/671 VGA controller
  • Joomla Tutorials
    • Hardening Joomla
    • Module Positions
    • Remove Joomla description meta tag
  • Looking Glasses
  • Optimize Firefox
  • Security
    • Crack WiFi WEP passwords
    • Defend against UDP isc.org DNS query DDOS
    • Detect DDoS attack
    • Remove malware from web sites
    • Sniff SSL passwords with ettercap
    • Snort2BGP
    • Track Hackers
    • What Is My IP
  • Troubleshooting
    • Grub error no such disk
    • named dumping master file: tmp-XXXXXXXXXX: open: permission denied
    • Nginx 413 Request Entity Too Large
    • SSH conection closed by remote host
    • Troubleshooting sis190.c
  • Unix Tutorials
    • FreeBSD reset root password
    • Installing snort on OpenBSD
    • Unix Toolbox
  • Virtualization Tutorials
    • Convert VirtualBox image to VMWare
    • VMware SNMP Enable
  • VoIP Tutorials
    • Install Elastix
    • Qos for Asterisk

Who's Online

We have 14 guests and no members online

Most Read

  • Setup SS5 Socks Proxy
  • Install webalizer with ispconfig
  • Sniff SSL passwords with ettercap
  • __404__
  • Optimize and Tune Apache for performance

Products and Services

  • Home
  • Linux Products and Services
  • Buy VPN Account
  • Privacy Policy for Linuxexpert
  • Remove malware

Setup awstats on CentOS

  • Print
  • Email
Details
Parent Category: Tutorials
Published: 01 March 2011
Hits: 26928

In this tutorial I'll show you how to install awstats on CentOS

From AWstats website: “AWStats is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. This log analyzer works as a CGI or from command line and shows you all possible information your log contains, in few graphical web pages. It uses a partial information file to be able to process large log files, often and quickly. It can analyze log files from all major server tools like Apache log files (NCSA combined/XLF/ELF log format or common/CLF log format), WebStar, IIS (W3C log format) and a lot of other web, proxy, wap, streaming servers, mail servers and some ftp servers.”


The installation procedure is done on a typical LAMP install on CentOS 6 x64_86

Your apache needs the combined log directive for the virtual host you are going to monitor with AWStats, so in your virtualhost you must have something like:

CustomLog logs/linuxexpert.ro-access_log combined

If you use the common log format some statistic features (browsers, os, keywords…) can’t work.


In this tutorial I am using linuxexpert.ro so change it with your own domain and docroot location.


As root install the rpmforge repository:


# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

# rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm


# yum install yum-priorities # if you have other repos you might want to add the priority options in the .repo file so you don’t mess up packages. More info


In case you are using i386 change the .x86_64 with .i386


# 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.linuxexpert.ro.conf # Change it to your domain


Edit the configuration file:


# vi /etc/awstats/awstats.linuxexpert.ro.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/linuxexpert.ro-access_log”


In line 153: change SiteDomain=”localhost.localdomain” to SiteDomain=”linuxexpert.ro”


In line 168: change HostAliases=”localhost 127.0.0.1″ to HostAliases=”www.linuxexpert.ro”


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

Ex: DirData=”/var/www/htdocs/linuxexpert.ro/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/linuxexpert.ro


Change the permissions to the awstats directory:


# chown -R localuser:apache /var/www/htdocs/linuxexpert.ro/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/linuxexpert.ro/awstats/icon/

ScriptAlias /awstats/ /var/www/htdocs/linuxexpert.ro/awstats/



<Directory /var/www/htdocs/linuxexpert.ro/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/linuxexpert.ro/awstats


# perl awstats.pl -config=linuxexpert.ro -update


If you see something like:


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

From data in log file “/var/log/httpd/linuxexpert.ro-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/linuxexpert.ro-access_log


run the update again:


# perl awstats.pl -config=linuxexpert.ro -update

Update for config "/etc/awstats/awstats.linuxexpert.ro.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://linuxexpert.ro/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=linuxexpert.ro -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!



REFERENCES

http://beginlinux.com/blog/2009/04/awstats-graphical-view-of-your-logs/

Note:

We use Hosting and VPS Hosting, from: www.star-host.org

We like and trust them.

Good prices, high security.

fShare
Tweet