Home / How To / How to install and use AWStats Web Analytics on CentOS 8

How to install and use AWStats Web Analytics on CentOS 8

AWStats is an open source advanced web analytics tool that generates advanced web, streaming, FTP or email server statistics graphically. It is written in the Perl language and acts as a CGI or from the command line. AWStats analyzes server log files and produces HTML reports in a nice graphical display.

AWSTATS has the following functions.

  • It supports most web server log formats, including Apache, IIS and many other web server log formats.
  • It can show the number of visits and unique visitors, the duration of the visit
  • Most viewed homepages
  • View visitor information (OS, browser, IP address, screen size, search engine, keyword phrase and keywords used to find your site)
  • it will be useful to monitor website traffic, how many visitors are to a website in a day / week / month, what browser they use, etc.

Step 1 – Configure the EPEL Repository

By default, the AWStats package is not available in the CentOS 8 repository. You must install the EPEL Yum repository on the server.

dnf install epel-release

Step 2 – Install Apache Server

AWStats required the Apache web server to run. Run the following command to install Apache Server.

sudo dnf install httpd

Then check the apache service, start apache manually and activate the apache service at start / start time.

sudo systemctl status httpd
sudo systemctl start httpd
sudo systemctl enable httpd

Step 3: Install AWStats

You can now install AWStats using the yum command as follows: –

sudo dnf install awstats

Step 4: Configure AWStats for Apache

By default, AWStats generates an Apache configuration file /etc/httpd/conf.d/awstats.conf. The default configuration for Awstats use allows from all access. To access Awstats from the specific network, change the IP permission with your system or network IP.

    Options None
    AllowOverride None
        # Apache 2.4
        Require ip

        # Apache 2.2
        Order allow,deny
        Allow from
        Allow from

Then you need to restart the Apache service to reload new settings

sudo apachectl restart

Step 5: Create the AWStats configuration file

You must create a configuration file for each site for which you want to view statistics. Here we create a configuration file for the domain example.com.

First, create a copy of AWStat’s default configuration file with your domain name: –

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

You will then need to make some changes to the configuration file: –

sudo vim /etc/awstats/awstats.example.com.conf

Edit the following lines

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

# Change to the website domain name
HostAliases="www.example.com localhost"

#set AllowToUpdateStatsFromBrowser=0 to AllowToUpdateStatsFromBrowser=1

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

sudo apachectl restart

Then you need to build your first statistics, which will be generated from the current logs on your server.

Run the following command for this,

sudo /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=example.com -update

The output looks like the following screenshot,

Run AWStats

Step 6: Set Cron to update the logs

Now we need to set up cronjob to regularly update the AWStats database with newly created log entries.

Then run the following command as root to set up cronjob

crontab -e

and add the following line

*/30 * * * * root /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=example.com -update

save and exit the file.

Step 7: Access AWStats in a web browser

You can now access AWStats with the following URL in your browser: –

http: //din.server.ip/awstats/awstats.pl? config = example.com /

You will need to replace example.com with your domain name in this tutorial.Advertisement


The AWStats page will look like the following screenshot:

AWStats Web Analytics

Finally, you have successfully configured AWStats in your system !.

Source link