How to install & configure AWStats (Apache Log Analyzer) on Linux Cloud Servers

2020-04-27 By Aaron 107572 Views linux awstats
2048 reviews

AWStats (Advanced Web Statistics) is a freely available analytics tool that is used to generate web/FTP/mail statistics by analyzing the available logs in a server. AWStats produces outputs in the form of an easily readable graphical format.

This can easily be installed on a Linux-based server. This guide outlines the basic steps involved in the installation of AWStats in a Linux server (provided Apache service is already installed in the server).


CentOS/Fedora:

The below steps can be followed to install and configure AWStats in a CentOS/Fedora server, which already has an Apache webserver running in it.


  1. Install and set up the EPEL Repository. The below command can be executed in order to install the EPEL repository on the server.

    # yum -y install epel-release
    

    AWStats1

  2. To install AWStats which the server already has Apache webserver installed in it, execute the below command to install AWStats and all required dependencies using YUM.

    # yum -y install awstats
    

    AWStats2

  3. Start to configure Apache for AWStats, the default AWStats configuration file is located at the path /etc/httpd/conf.d/awstats.conf. This default configuration is useful except in cases of allowing from access. If AWStats needs to be accessed externally from a specific network, the IP address of the network needs to be allowed in the AWStats configuration file.

    For this, open the AWStats configuration file using any editor:

    # vi /etc/httpd/conf.d/awstats.conf
    

    Add in the network IP (example: 123.123.123.123) using Allow from directive as per below.

    AWStats3

    Restart Apache service for the changes to be made effective:

    # systemctl restart httpd
    

    AWStats4

  4. Create AWStats configuration files for websites now. Each of the websites hosted in the server needs to have its own AWStats configuration file. For this copy the AWStats example configuration file with a new name (preferably with the website name) and make changes as below.

    # cp /etc/awstats/awstats.localhost.localdomain.conf /etc/awstats/awstats.layerstacksupport.com.conf
    

    Note: The website name has been considered as layerstacksupport.com as an example in the above command.

    AWStats5

    Open the newly renamed website configuration file using any editor:

    # vi /etc/awstats/awstats.layerstacksupport.com.conf
    

    Update below settings in the configuration file:

    LogFile="/var/log/httpd/layerstacksupport.com-access_log"
    
    SiteDomain="layerstacksupport.com"
    
    HostAliases="layerstacksupport.com www.layerstacksupport.com"
    

    Execute below command for updating the log files:

    # perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=layerstacksupport.com -update
    

    AWStats6

  5. Create a cronjob to update the AWStats database on a regular basis using newly created log entries from the server.

    Open the crontab using any editor:

    # vi /etc/crontab
    

    Add the below line to the end of the crontab file:

    0 2 * * * /usr/bin/perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=****layerstacksupport.com** **-update
    
  6. AWStats can now be accessed through a browser using the server IP in the format of the below link.

    https://<server_ip>/awstats/awstats.pl?config=layerstacksupport.com
    

    AWStats7


Ubuntu/Debian:


The below steps can be followed to install and configure AWStats in a Ubuntu/Debian server, which already has an Apache webserver running in it.


  1. Execute the below command to install AWStats and all its related dependencies.

    # sudo apt-get install awstats
    

    AWStats8

  2. An Apache configuration file needs to be created for the AWStats setup. For this, create a new AWStats configuration file using any editor.

    # sudo vi /etc/apache2/conf-available/awstats.conf
    

    Add in the below configuration settings, where 123.123.123.123 denotes the network IP address from which the AWStats is to be accessed.

    AWStats9

    Enable the CGI/CGID module (if it is not enabled already) and also enable the AWStats apache configuration by running the below commands:

    # sudo a2enmod cgi
    
    # sudo a2enconf awstats
    

    AWStats10

    Restart Apache service for the changes to be made effective:

    # systemctl restart apache2
    

    AWStats11

  3. Create AWStats configuration files for websites now. Each of the websites hosted in the server needs to have its own AWStats configuration file. For this copy the AWStats example configuration file with a new name (preferably with the website name) and make changes as below.

    # sudo cp /etc/awstats/awstats.conf /etc/awstats/awstats.layerstacksupport.com.conf
    

    Note: The website name has been considered as layerstacksupport.com as an example in the above command.

    AWStats12

    Open the newly renamed website configuration file using any editor:

    # vi /etc/awstats/awstats.layerstacksupport.com.conf
    

    Update below settings in the configuration file:

    LogFile="/var/log/apache2/layerstacksupport.com-access_log"
    
    SiteDomain="layerstacksupport.com"
    
    HostAliases="layerstacksupport.com www.layerstacksupport.com"
    

    Execute the below command for updating the log files:

    # sudo /usr/lib/cgi-bin/awstats.pl -config= layerstacksupport.com -update
    
  4. AWStats can now be accessed through a browser using the server IP in the format of the below link.

    https://<server_ip>/awstats/awstats.pl?config=layerstacksupport.com
    

    AWStats13


Related Tutorials

What do you think about this article?

Rate this article
LayerStack Promotion
Need assistance?

Try this guide to receive free bundled services at signup on a new free account.

Sign Up

Your Feedback Is Important

We hope you’ll give the new products and updates a try. If you have an idea for improving our products or want to vote on other user ideas so they get prioritized, please submit your feedback on our Community platform. And if you have any questions, please feel free to ask in the Community or contact our Technical Support team.