How to Install and Configure AWStats on CentOS 7

By | October 29, 2016


AWStats is a free (and very useful) web analytics reporting tool which generates advanced web, streaming, FTP, or mail server statistics. AWStats analyzes server log files and produces HTML reports in a nice graphical display.

The AWStats log analyzer works as either a CGI program or from the command line. It presents all the information contained your log files in a few easy-to-read web pages. It supports most web server log file formats including Apache and IIS.

In this tutorial, I will explain how to install and configure AWStats on CentOS 7


  • A server running CentOS v. 7 with Apache installed
  • A static IP Address for your server

Install the AWStats package

By default the AWStats package is not available in the CentOS 7 repository. You will need to install the EPEL Yum repository on the server.

You can install and enable the EPEL repository by running the following command:

sudo rpm -ivh

Next, install the awstats package using Yum. This will also install all other required dependencies.

sudo yum --enablerepo=epel install awstats

Configure AWStats for Apache

By default AWStats creates an Apache configuration file /etc/httpd/conf.d/awstats.conf. If you need to access AWStats from the network, then you need to update the Allow from and Require with your server’s IP address.

You can do this by editing the AWStats config file:

sudo nano /etc/httpd/conf.d/awstats.conf

Update the following lines as shown below. Substitute your own IP address for the sample address

<Directory "/usr/share/awstats/wwwroot">
    Options None
    AllowOverride None
    <IfModule mod_authz_core.c>
        # Apache 2.4
        Require ip
    <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order allow,deny
        Allow from
        Allow from

Restart the Apache service to reload new settings

sudo apachectl restart

Create an AWStats configuration file

You need to create a configuration file for each website for which you wish to view statistics. Here, we will create a configuration file for the domain.

First, create a copy of the default AWStats configuration file with your domain name:

sudo cp /etc/awstats/awstats.localhost.localdomain.conf etc/awstats/

Next you will need to make some changes in the config file:

sudo nano /etc/awstats/

Update the following lines:

# Change to Apache log file, by default it's /var/log/apache2/access.log

# Change to the website domain name
HostAliases=" localhost"

# When this parameter is set to 1, AWStats adds a button on report page to allow to "update" statistics from a web browser

Save and close the file. Restart the Apache service to reload the new settings:

sudo apachectl restart

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:

sudo /usr/share/awstats/wwwroot/cgi-bin/ -update

The output will look something like this:

From data in log file "/var/log/httpd/access_log"...
Phase 1 : First bypass old records, searching new record...
Direct access after last parsed record (after line 209)
Jumped lines in file: 209
Found 209 already parsed records.
Parsed lines in file: 0
Found 0 dropped records,
Found 0 comments,
Found 0 blank records,
Found 0 corrupted records,
Found 0 old records,
Found 0 new qualified records.</code></pre>

Set up Cron to update the logs

It is a good idea to set up a cron job to regularly update the AWStats database using newly-created log entries. This will save you time, as well as ensure that the stats are updated on a regular basis.

You can do this by editing /etc/crontab file:

sudo nano /etc/crontab

Add the following line:

*/30 * * * * root /usr/share/awstats/wwwroot/cgi-bin/ -update

Save and close the file.

Access AWStats in a browser

Now you can access your AWStats by visiting the URL: http://your.server.ip/awstats/ (Change the domain name at the end of the URL to match your own.)

It will show you a result page like this:

Example AWstats report


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.