[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

awstats configuration and installation



hi,

after installing awstats package on sarge it took a bit of figuring out how
to configure it.

here are my notes which may help someone or mey help the awstats package
maintainer.



Installation of awstats 


 The awstats package was chosen because it seems to be the most advanced log
file analyser. 

 Here we describe how to install awstats to get stats pages for individual
virtual hosts on Apache. 

 Installation is initially carried out via apt - but then the rest is fairly
tricky and needs to be carried out manually. 

 

Install awstats package 


 
server1:~# apt-get -s install awstats


 

Set up log files 


 The log files for the individual sites need to be set up. This is set in
the VirtualHost? directive. Note the 'combined' directive which tells
Apache what format of log file to produce. 

 
<VirtualHost *>
    DocumentRoot /home/svs/public_html
    ServerName www.example2.co.uk
    CustomLog /var/log/apache/www.example2.co.uk-access.log combined
    ErrorLog /var/log/apache/www.example2.co.uk-error.log
</VirtualHost>


 Then checked and restarted Apache 
server1:~# apachectl configtest
Syntax OK
server1:~# apachectl graceful
/usr/sbin/apachectl graceful: httpd gracefully restarted
server1:~#


 

Alter logrotate 


 Changed the 'create' setting in /etc/logrotate.d/apache from 640 to 644. 

 This means that the Apache log files are readable by everyone. No security
issue was mentioned with regards this setup. 

 If necessary I would think that the logrotate setting could be set only for
only the log files which awstats is accessing. 

 
server1:~# nano /etc/logrotate.d/apache
server1:~# cat /etc/logrotate.d/apache
/var/log/apache/*.log {
        weekly
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 644 root adm
        sharedscripts
        postrotate
           if [ -f /var/run/apache.pid ]; then \
             if [ -x /usr/sbin/invoke-rc.d ]; then \
                invoke-rc.d apache reload > /dev/null; \
             else \
                /etc/init.d/apache reload > /dev/null; \
             fi; \
           fi;
        endscript
}


 

Make existing log files accessible 


 To check everything is working we need to make the existing log files
accessible to awstats. 

 
server1:/var/log/apache# chmod 644 www.example2.co.uk*


 

Alter Apache configuration 


 Now we will run the awstats_configure.pl script which will set up certain
parts of the Apache configuration. 

 This fails when trying to create a build a profile - so best just to select
'N'. 

 So all we are using this script for is to update the httpd.conf file so
that awstats is accessible and the cgi scripts will work. 

 
server1:/usr/share/doc/awstats/examples# ./awstats_configure.pl

----- AWStats awstats_configure 1.0 (build 1.4) (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
Warning: AWStats standard directory on Linux OS is '/usr/local/awstats'.
If you want to use standard directory, you should first move all content
of AWStats distribution from current directory:
/usr/share/doc/awstats/examples
to standard directory:
/usr/local/awstats
And then, run configure.pl from this location.
Do you want to continue setup from this NON standard directory [yN] ? y

-----> 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/apache/httpd.conf

-----> Check and complete web server config file '/etc/apache/httpd.conf'
  Add 'Alias /awstatsclasses
"/usr/share/doc/awstats/examples/wwwroot/classes/"'
  Add 'Alias /awstatscss "/usr/share/doc/awstats/examples/wwwroot/css/"'
  Add 'Alias /awstatsicons "/usr/share/doc/awstats/examples/wwwroot/icon/"'
  Add 'ScriptAlias /awstats/
"/usr/share/doc/awstats/examples/wwwroot/cgi-bin/"'
  Add '<Directory>' directive
  AWStats directives added to Apache config file.

-----> 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] ?
N


 Then restarted Apache again so the new configuration is picked up. 

 

Set up a profile 


 Each profile basically means that awstats will process a particular log
file and produce a database file from the data in the log file. The script
which carries out this processing is called awstats.pl. 

 This data is accessed from a browser by selecting the awstats cgi script
and passing it a parameter which says which database file to process and
display. 

 Basically, copy the example file and modify it to suit. 

 

server1:/etc/awstats# ls -l
total 68
-rw-r--r--  1 root root 58363 Nov  9 16:53 awstats.conf
-rw-r--r--  1 root root   240 Nov  9 16:53 awstats.conf.local
server1:/etc/awstats# cp awstats.conf awstats.www.example2.co.uk.conf


 Now we need to edit this file. 

 Particularly we need to change: 

 
LogFile - Set to the log file set in the virtual hosts directive earlier. 
LogFormat - This needs changing from 4 to 1 to match the 'combined'
directive. 
SiteDomain - Set to the web address of the site we are creating stats for -
this was set in the virtual hosts directive. 
AllowToUpdateStatsFromBrowser - Set this to 1 to enable an update button on
the stats screen. 
DefaultFile - Needed to be changed to index.php. Not sure if this make much
difference. 

 

View the stats and run an update. 


 Now go to:
http://www.example.com/cgi-bin/awstats.pl?config=www.example2.co.uk 


(note this is different from the official docs which show:
http://www.myserver.mydomain/awstats/awstats.pl?config=mysite)



 This should give us a page with no current stats. 

 According to the docs it should be possible to run awstats.pl from the
command line. But it was found that clicking the 'Update' link carries this
out. 

 NB - It remains to be checked whether the Debian install sets cron to
update the stats DB files regularly. 

NB - this does not look like it is happening.  also, once files have been
rotated and tarred up they are no longer processed by awstats.  this means
that it is important to run the stats program every night.

also, what is confusing - the file awstats.pl seems to carry out 2 tasks.

1. it processes the apache log files and produces the awstats database file.

2. it processes the awstats database files and produces an html file for
viewing the stats.
 

Get the icons to work 


 Needed to add 

 Alias /awstats-icon/ /usr/share/awstats/icon/ 

 to /etc/apache/httpd.conf to get the icons to work.


HTH someone,

kev



Reply to: