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 analysis tool that can graphically generate advanced web, streaming, FTP or mail server statistics. It is written in Perl language and can be used as CGI or from the command line. AWStats can analyze server log files and generate HTML reports in the form of beautiful graphs.

AWSTATS has the following functions.

  • It supports most web server log file formats, including Apache, IIS and many other web server log formats.
  • It can display the number of visits, unique visitors, visit duration
  • Most viewed exit page
  • Display information about visitors (operating system, browser, IP address, screen size, search engine, keywords and keywords used to find your website)
  • This is very useful for monitoring website traffic, how many visitors are there in a day/week/month, web browsers being used, etc.

Step 1-set up EPEL repository

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

dnf install epel-release

Step 2-Install Apache server

AWStats requires that the Apache web server is running. Run the following command to install Apache Server.

sudo dnf install httpd

Next, check the apache service, start apache manually, and enable the apache service at startup/startup.

sudo systemctl status httpdsudo systemctl start httpdsudo systemctl enable httpd

Step 3: Install AWStats

Now you can install AWStats using the yum command as follows:

sudo dnf install awstats

Step 4: Configure AWStats for Apache

By default, AWStats will generate an Apache configuration file /etc/httpd/conf.d/awstats.conf. The default configuration used by Awstats allows all access. If you want to access Awstats from a specific network, please use the system or network IP to modify the IP permission.

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

Next, you need to restart the Apache service to reload the new settings

sudo apachectl restart

Step 5: Create AWStats configuration file

You need to create a profile for each website whose statistics you want to view. Here, we will create a configuration file for the example.com domain.

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

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

Next, you will need to make some changes in 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.logLogFile="/var/log/httpd/access.log"# Change to the website domain nameSiteDomain="example.com"HostAliases="www.example.com localhost 127.0.0.1"#set AllowToUpdateStatsFromBrowser=0 to AllowToUpdateStatsFromBrowser=1AllowToUpdateStatsFromBrowser=1

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

sudo apachectl restart

Next, you need to build the initial statistics, which will be generated from the current logs on the server.

To do this, run the following command,

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

The output looks like the screenshot below,

Step 6: Set up the Cron update log

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

Next, run the following command as root user to set up cronjobAdvertisement

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: Visit AWStats in a web browser

Now you can access AWStats using the following URL in a web browser:

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

In this tutorial, you need to replace example.com with the domain name.

The AWStats page will resemble the following screenshot:

AWStats web analysis

Finally, you have successfully configured AWStats in the system!

Sidebar