How to Set Up AWStats On Ubuntu Server

AWStats is an open-source Web analytics reporting tool that generates advanced web, streaming, FTP or mail server statistics graphically. This log analyser works as a CGI or from command line and shows you all the possible information your log contains in a few graphical web pages. It uses a partial information file to be able to process large log files often and quickly. It supports most web server log file formats including Apache, IIS and many other web server log formats.

This article will help you to install and configure AWStats on Ubuntu.

By default, AWStats package is available in the Ubuntu repository.

You can install it by running:

Next you will need to enable the CGI module in Apache.

You can do this by running:

Now, restart Apache to reflect the changes.

You need to create a configuration file for each domain or website you wish to view statistics for. In this example we will create a configuration file for “test.com“.

You can do this by duplicating the AWStats default configuration file to one with your domain name.

Now, you need to make some changes in the config file:

Update the settings shown below:

Save and close the file.

After these changes, you need to build your initial statistics which will be generated from the current logs on your server. You can do this using:

The output will look something like this:

awtstats

Next, you need to configure Apache2 to show these stats. Now copy the content of the “cgi-bin” folder to the default document root directory of your Apache installation. By default, this is in the “/usr/lib/cgi-bin” folder.

You can do this by running:

Now you can access your AWStats by visiting the url “http://your-server-ip/cgi-bin/awstats.pl?config=test.com.”
It will show you a results page like this:

awstats_page

It is recommended to schedule a cron job to regularly update the AWStats database using newly created log entries, so the stats get updated on a regular basis. This will also save your time.

To do this you need to edit the “/etc/crontab” file:

Add the following line that tells AWStats to update every ten minutes.

Save and close the file.

AWStats is a very useful tool that can give you an overview of what is happening on your website and assist with site analysis. It is very easy to install and configure. Feel free to comment below if you have any questions.