AWStats is a powerful and flexible tool for analyzing web traffic, providing detailed statistics about visitors, traffic sources, and user behavior on websites. By processing web server logs, it offers an in-depth view of how users interact with your sites. In this article, you'll learn how to install, configure, and use AWStats on CentOS to empower your websites with valuable insights.
Installing AWStats on CentOS
The first step is to install AWStats on your CentOS server. AWStats is available in default repositories, making its installation straightforward:
-
Open a terminal and log in to your server as a user with sudo privileges.
-
Execute the following command to install AWStats:
sudo yum install awstats
Configuring AWStats for Your Website
After installation, AWStats needs to be configured for your specific website:
-
Create a new configuration file for your website by copying the sample configuration file. Let's assume your domain name is
example.com
:sudo cp /etc/awstats/awstats.localhost.localdomain.conf /etc/awstats/awstats.example.com.conf
-
Open the newly created configuration file in a text editor:
sudo nano /etc/awstats/awstats.example.com.conf
-
Make the following changes in the configuration file:
- Set
LogFile
to the path of your web server's log file. For Apache, it might be/var/log/httpd/access_log
, for Nginx/var/log/nginx/access.log
. - Change
LogFormat
to 1, which is the standard log format for most web servers. - Adjust
SiteDomain
to your domain name, in this exampleexample.com
. - Add
HostAliases
for aliases of your domain, such aswww.example.com
.
- Set
Generating Statistics
After configuring, you can start generating statistics:
-
Use the following command to manually update AWStats statistics for your website:
sudo /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -update -config=example.com
-
For displaying statistics through the web interface, your web server needs to be set up to serve AWStats files. For Apache, you can add the following directives to your virtual host configuration:
Alias /awstatsclasses "/usr/share/awstats/wwwroot/classes/" Alias /awstatscss "/usr/share/awstats/wwwroot/CSS/" Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/" ScriptAlias /awstats/ "/usr/share/awstats/wwwroot/cgi-bin/"
Remember to restart Apache after making changes.