Awstats Installation
Step: 1
i. Login to the server you want to install awstats
ii. Download awstats-6.95 from the below link.
iii. Unpack the tar file.
#tar -xvzf awstats-6.95.tar.gz
iv. The above command creates a directory as awstats-6.95.
v. Copy this directory to the /usr/local
#cp -rp awstats-6.95 /usr/local
vi. Change the directory.
#cd /usr/local
vii. Rename the directory.
#mv awstats-6.95 awstats
Step: 2
i. Change the directory to /usr/local/awstats/tools
#cd /usr/local/awstats/tools
ii. Configure awstats.
#perl awstats_configure.pl
iii. It’ll ask for the httpd.conf path. Don’t give any path because it’ll edit the httpd.conf file
>none
iv. It’ll ask to create an awstats conf file (by default the file is created in /etc/awstats)
>demo
(it’ll copy the awstats.model.conf to awstats.demo.conf in the directory /etc/awstats
(it’ll copy the awstats.model.conf to awstats.demo.conf in the directory /etc/awstats
It is a demo conf file for awstats)
v. Press enter to end the configuration.
Step: 3
i. Change the directory to /usr/local/awstats/wwwroot/
#cd /usr/local/awstats/wwwroot
ii. Copy all the contents of this directory to the Document Root of the Apache service(in our case the default path for http is used - /var/www/html)
#cp –rp cgi-bin/* /var/www/html/cgi-bin
(NOTE: This directory may be different according to your document root, don’t type the command as #cp -rp cgi-bin /var/www/html it will replace your original cgi-bin directory).
#cp –rp classes /var/www/html
(NOTE: This directory may be different according to your document root).
(NOTE: This directory may be different according to your document root).
#cp –rp css /var/www/html
(NOTE: This directory may be different according to your document root).
(NOTE: This directory may be different according to your document root).
#cp –rp js /var/www/html
(NOTE: This directory may be different according to your document root).
(NOTE: This directory may be different according to your document root).
#cp –rp icon /var/www/html
(NOTE: This directory may be different according to your document root).
(NOTE: This directory may be different according to your document root).
Step: 4
i. Add the contents in the httpd.conf file.
#vi /etc/httpd/conf/httpd.conf
Press i
Type or copy the below contents at the end of the file
Alias /awstatsclasses "/var/www/html/classes/"
Alias /awstatscss "/var/www/html/css/"
Alias /awstatsicons "/var/www/html/icon/"
Alias /awstatscss "/var/www/html/css/"
Alias /awstatsicons "/var/www/html/icon/"
Save and quit from vi editor
ii. Restart httpd service.
#/etc/init.d/httpd restart OR service httpd restart
Step: 5
i. Copy the awstats conf file as your virtual domain
#cp /etc/awstats/awstats.demo.conf /etc/awstats.mydomain.com.conf
ii. Edit the conf file
#vi /etc/awstats/awstats.mydomain.com.conf
Logfile=” path of access log file for your domain” (e.g /var/log/http/access.log)
Logtype=w (w=web, m=mail ..... which type of log you want to analyze)
LogFormat=1 (default is 1, may be your apache log format is different than default. You have to check and mention according)
Domain=”mydomain.com”
HostAlias=”mydomain.com www.mydomain.com”
Save and quit from vi editor
iii. Repeat the (i) and (ii) for each and every virtual host.
iv. Create a directory for the awstats database.
#mkdir /var/lib/awstats
(If you want to update your analyze from wab page you must change the permission of this directory to writable for all #chmod +w /var/lib/awstats)
(If you want to update your analyze from wab page you must change the permission of this directory to writable for all #chmod +w /var/lib/awstats)
Step: 6
i. Update the awstats for individual virtual host.
#perl /var/www/html/cgi-bin/awstats.pl –config=mydomain.com –update
OUTPUT OF THIS COMMAND
Update for config "/etc/awstats/awstats.mydomain.com.conf"
With data in log file "/pathtoyourlog/yourlog.log"...
Phase 1: First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2: Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 225730
Found 122 dropped records,
Found 87 corrupted records,
Found 0 old records,
Found 225521 new qualified records.
With data in log file "/pathtoyourlog/yourlog.log"...
Phase 1: First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2: Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 225730
Found 122 dropped records,
Found 87 corrupted records,
Found 0 old records,
Found 225521 new qualified records.
ii. Create the static pages.
#perl /usr/local/awstats/tools/awstats_buildpages.pl –config=mydomain.com –output
–dir=”path of the directory inside the documentroot where you want to store the pages”
(NOTE: you must create the directory before this command)
iii. Insert a cron job for updating the logs.
iv. Creating a link for index page
#ln /path of the directory where you store the pages/awstats.mydomain.com.html
/path of the directory where you store the pages/index.html