Configure Apache Server : Log Monitoring : AWSTATS : Part-3

Configure Apache Server : Log Monitoring : AWSTATS : Part-3

by -
0 2057

AWStats (Advanced Web Statistics) is a free powerful tool that generates advanced web (but also ftp or mail) server statistics, graphically, broadly used also with WHM.

Following are the steps to configure AWStats on CentOS and RHEL system.

Step1:  Installation of awstats

# wget http://sourceforge.net/projects/awstats/files/AWStats/7.0/awstats-7.0-1.noarch.rpm

# rpm -ivh awstats-7.0-1.noarch.rpm
Preparing…                ########################################### [100%]
1:awstats                ########################################### [100%]

—– AWStats 7.0 – Laurent Destailleur —–
AWStats files have been installed in /usr/local/awstats

If first install, follow instructions in documentation
(/usr/local/awstats/docs/index.html) to setup AWStats in 3 steps:
Step 1 : Install and Setup with awstats_configure.pl (or manually)
Step 2 : Build/Update Statistics with awstats.pl
Step 3 : Read Statistics

Note:  sometime required dependencies if perl is not fully loaded, then run this command
yum install perl-libwww-perl.noarch

Step2:  Configure and setup AWstats with awstats_configure.pl

# cd /usr/local/awstats/tools
# ./awstats_configure.pl

./awstats_configure.pl

—– AWStats awstats_configure 1.0 (build 1.9) (c) Laurent Destailleur —–
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
– You are not an administrator user,
– You want to analyze downloaded log files without web server,
– You want to analyze mail or ftp log files instead of web log files,
– You need to analyze load balanced servers log files,
– You want to ‘understand’ all possible ways to use AWStats…
Read the AWStats documentation (docs/index.html).
—–> Running OS detected: Linux, BSD or Unix
—–> Check for web server install

Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path (‘none’ to skip web server setup):
> /etc/httpd/conf/httpd.conf    –> Enter Apache configuration path   <–here you have to enter path for config file

—–> Check and complete web server config file ‘/etc/httpd/conf/httpd.conf’
Warning: You Apache config file contains directives to write ‘common’ log files
This means that some features can’t work (os, browsers and keywords detection).
Do you want me to setup Apache to write ‘combined’ log files [y/N] ? y
Add ‘Alias /awstatsclasses “/usr/local/awstats/wwwroot/classes/”‘
Add ‘Alias /awstatscss “/usr/local/awstats/wwwroot/css/”‘
Add ‘Alias /awstatsicons “/usr/local/awstats/wwwroot/icon/”‘
Add ‘ScriptAlias /awstats/ “/usr/local/awstats/wwwroot/cgi-bin/”‘
Add ‘<Directory>’ directive
AWStats directives added to Apache config file.

—–> Update model config file ‘/etc/awstats/awstats.model.conf’
File awstats.model.conf updated.

—–> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y

—–> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> abc.local

—–> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
>

—–> Create config file ‘/etc/awstats/awstats.abc.local.conf’
Config file /etc/awstats/awstats.abc.local.conf created.

—–> Restart Web server with ‘/sbin/service httpd restart’
Stopping httpd:                                            [  OK  ]
Starting httpd:                                             [  OK  ]

—–> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.anup.co.in
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue…

A SIMPLE config file has been created: /etc/awstats/awstats.abc.local.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for ‘abc.local’ with command:
> perl awstats.pl -update -config=abc.local
You can also read your statistics for ‘abc.local’ with URL:
> http://localhost/awstats/awstats.pl?config=abc.local

Press ENTER to finish…

 

Step 3:  Update Awstats

[root@mail1 tools]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update –config=abc.local
Error: AWStats database directory defined in config file by ‘DirData’ parameter (/var/lib/awstats) does not exist or is not writable.
Setup (‘/etc/awstats/awstats.abc.local.conf’ file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in ‘docs’ directory).

# mkdir -p /var/lib/awstats
Now configure your website config file:
# vi /etc/awstats/awstats.abc.local.conf
change >

#
#LogFile=”/var/log/httpd/mylog.log”
LogFile=”/var/log/httpd/access_log”    < —modify this

Again run the command now

# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update –config=abc.local
Create/Update database for config “/etc/awstats/awstats.abc.local.conf” by AWStats version 7.0 (build 1.971)
From data in log file “/var/log/httpd/access_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: 40
Found 0 dropped records,
Found 0 comments,
Found 0 blank records,
Found 0 corrupted records,
Found 0 old records,
Found 40 new qualified records.

Step 4: Scheduling to update awstat for every 30 minute.

# crontab -e
*/30 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=abc.local

 

Step 5:  Enable Authentication

To enable Directory Authentication on folder /usr/local/awstats/cgi-bin
Open the httpd.conf file and following lines at the end of file.

[root@server ~]# vi /etc/httpd/conf/httpd.conf

<Directory “/usr/local/awstats/cgi-bin”>
Order allow,deny
Allow from all
</Directory>

# This is to force authentication when trying to access /awstats

<Location /awstats>
AuthType Basic
AuthName “AWStats Enter Password”
AuthUserFile /etc/httpd/awstats.passwd
require valid-user
</Location>

# htpasswd -c  /etc/httpd/awstats.passwd vikas
New password:
Re-type new password:
Adding password for user vikas
You have new mail in /var/spool/mail/root

# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                              [  OK  ]

 

now access awstats url and check it.
http://localhost/awstats/awstats.pl?config=abc.local   <– on  the server  browser

or

http://abc.local/awstats/awstats.pl?config=abc.local

 

awstats

 

 

 

 

It shows  various options and information about site abc.local

That’s it….!!

Enjoy Linux… It works !!

CEO, KV IT-Solutions Pvt. Ltd. | vikas@kvit.in | 9810028374|
Linux Professional and an Industrial Trainer | 20 + years Experience in IT Industry

” We are born free, No Gate and Windows can snatch our freedom “

Download PDF

SIMILAR ARTICLES

0 889

0 572

NO COMMENTS

Leave a Reply

Required Captcha *