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

Install AWStats Package

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.

Configure AWStats

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:

Configure Apache For AWStats

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:

Test AWStats

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:

Set Up Cron to Update Logs

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.

Conclusion

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.