Set up AWStats on Ubuntu

AWStats can be installed with these few simple steps.

Installation & Configuration

  1. Install AWStats

sudo apt-get install awstats

  1. Create a configuration file for your domain by copying the default configuration file.

sudo cp /etc/awstats/awstats.conf /etc/awstats/awstats.www.mydomain.com.conf

  1. Edit the new configuration file

sudo vim /etc/awstats/awstats.www.mydomain.com.conf

and make the following changes as needed.

SiteDomain="www.mydomain.com" HostAliases="www.myotherdomain.com" // if you use more than one domain name enter the other name here DefaultFile="index.php" // your default start page, usually index.html or index.php LogFile="/var/log/apache2/access.log" LogFormat=1 // Probable default for most linux distributions (Ubuntu, Debian, Fedora, Redhat...) UseHTTPSLinkForUrl=”/” // if your whole site is also accessible via https:// you should set this value to /

  1. Test the configuration by creating the first stats for this domain

/usr/lib/cgi-bin/awstats.pl -config=www.mydomain.com -update

  1. Create an Apache configuration file /etc/apache2/conf.d/awstats with the following content

Alias /awstatsclasses /usr/share/awstats/lib/ Alias /awstats-icon/ /usr/share/awstats/icon/ Alias /awstatscss /usr/share/doc/awstats/examples/css ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ ScriptAlias /awstats/ /usr/lib/cgi-bin/ <Directory /usr/lib/cgi-bin/> Options ExecCGI -MultiViews +SymLinksIfOwnerMatch Require valid-user AuthType Basic Authname "Welcome" AuthUserFile /etc/awstats/htpasswd

  1. Create a user name (here called admin) and a password for logging in to the statistics

htpasswd -c /etc/awstats/htpasswd admin

  1. Reload Apache to apply the changes.

/etc/init.d/apache2 reload

You should now be able to login with the user admin and your password at http://www.mydomain.com/awstats/awstats.pl and see your statistics.

  1. Add a cron job so that the statistics will be automatically updated.

0 */10 * * * /usr/lib/cgi-bin/awstats.pl -config=www.mydomain.com -update > /dev/null

Set up further domains

To set up additional domains just repeat steps 2, 3 and 4 and reload Apache with

/etc/init.d/apache2 reload

Links

AWStats Official Web Site: http://awstats.sourceforge.net

Set up AWStats on Ubuntu
Share this