AWStats is an open source web analytics Reporting tool that generates access charts for powerful websites, streaming media, FTP, or mail servers. This Log Parser works on a CGI or command-line basis and displays all of the information in your log as if it were a chart in the Web page. It can "partially" read information files so that a large number of log files can be processed frequently and quickly. It supports the vast majority of Web server log file formats, including Apache,iis.
Installing the AWStats Package
By default, AWStats packages can be found in the Ubuntu repository.
You can install by running the following command:
sudo apt-get install awstats
Next, you need to enable the Apache CGI module.
Run the following command to start the CGI:
sudo a2enmod cgi
Now, restart Apache for the change to take effect.
sudo /etc/init.d/apache2 restart
Configure AWStats
You need to create a profile for each domain or site that you want to view statistics for. In this example, we will create a configuration file for "test.com".
To complete this step, you can configure the domain you want to count by copying the default configuration file for AWStats.
sudo cp/etc/awstats/awstats.conf /etc/awstats/awstats.test.com.conf
Now you need to make some changes in the configuration file:
sudo vim /etc/awstats/awstats.test.com.conf
Add directly to the last:
#Change to Apache log file, by default it‘s /var/log/apache2/access.log
LogFile="/var/log/apache2/access.log"
# Change to the website domain name
SiteDomain="test.com"
HostAliases="www.test.com localhost 127.0.0.1"
# When this parameter is set to 1, AWStats adds a button on report page to allow to "update" statistics from a web browser
AllowToUpdateStatsFromBrowser=1
Save and close the file.
After modifying the configuration file, you need to establish preliminary statistics using the server's current log. You can do this:
sudo /usr/lib/cgi-bin/awstats.pl -config=test.com -update
Configure Awstats for Apache to update the log by setting a timer task
It is recommended that you create a timed task that periodically updates the AWStats database with the newly created log entries, and the statistics are updated periodically. This will also save you time.
To do this, you need to edit the "/etc/crontab" file:
sudonano/etc/crontab
Add the following line to let AWStats update every 10 minutes.
*/10 * * * * root /usr/lib/cgi-bin/awstats.pl -config=test.com -update
Save and close the file.
Conclusion
AWStats is a very useful tool that lets you know the status of your website and helps you analyze your website. It is very easy to install and configure. If you have any questions, please leave a comment below.
Next, you need to configure APACHE2 to display the statistics. Now you need to copy the contents of the "Cgi-bin" folder to the Apache default root directory. By default it is in "/usr/lib/cgi-bin".
Run the following command to complete this step:
sudo cp-r /usr/lib/cgi-bin /var/www/html/
-
sudo chown Www-< Span class= "PLN" >data:www-data /var/www/ html/cgi-bin
sudo chmod-R 755 /var/www/html/cgi-bin/
Test AWStats
You can now view the Awstats page by visiting the URL "http://your-server-ip/cgi-bin/awstats.pl?config=test.com."
Its page looks like this:
Configuring AWStats in Ubuntu server