More articles:
2017   2018   2019   2020   2021
2022   2023   2024   

2019-08-27 00:00:00

Publishing|Technologyaccess rights|analytics|apache|Awstats|debian|statistics|web site|Wordpress

How to install and configure Awstats web statistics for Wordpress and for other sites

Published 2019-08-27, Updated 2020-07-06 with settings for different types of URLs.

Awstats is a statistics/analysis tool that collects data from visitors who view a web site. It tallies up data into a database so that you can view historical statistics and compare it to today's numbers. Awstats gets its data from a web server log files, such as Apache, that exist on every web site. Awstats can analyze web, email, and ftp server data. Statistics for the number of visitors, most visited pages, referrers, search engines, browser products, keywords, and other information is displayed on the dashboard.

I am administering Wordpress sites that already are collecting statistics inside the CMS (content management system) using plugins. Wordpress plugins, however don't have a clue what is happening outside its own world. That's where Awstats, Webalizer and similar statistic tools can help. They provide valuable information about search engines, keywords, possible hackers, and many other things web site admins want to be aware of.

This Awstats installation and configuration guide has been tested on Debian 8 (Jessie) and Debian 10 (Buster), both running Apache 2.4. I happen to run Wordpress servers, but Awstats doesn't make a difference if you are running Drupal, Joomla, or another server. If you are running a Windows server, this article has instructions for it.

You should be comfortable with editing Linux configuration files to succeed with the Awstats installation. It also means you need root access to the system (or sudo).

Install Awstats on Debian

Open Terminal access to your server and type the installation command:
apt-get install awstats

Once the installation routine is completed, make a copy of the Awstats definitions file:
cp /etc/awstats/awstats.conf /etc/awstats/awstats.mysite.com.conf
(replace mysite.com with your actual domain name)

Edit the file awstats.mysite.com.conf as follows (these are the default values that usually work):
LogFile="/var/log/apache2/access.log"
LogFormat=1
SiteDomain="mysite.com"
HostAliases=”www.mysite.com mysite.com”
DNSLookup=0
AllowFullYearView=3
LoadPlugin="tooltips"

Open the Apache configuration file /etc/apache2/sites-available/mysite.conf (mysite is your conf file name) and insert the following lines into the file:
Alias /awstatsclasses "/usr/share/awstats/lib/"
Alias /awstats-icon/ "/usr/share/awstats/icon/"
Alias /awstatscss "/usr/share/doc/awstats/examples/css"
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ScriptAlias /awstats/ /usr/lib/cgi-bin/
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

Type the following commands to activate the changes in the Apache configuration:
a2enmod cgi
systemctl restart apache2

You can see how the installation is progressing by pointing your web browser to:
http://mysite.com/cgi-bin/awstats.pl

If a statistics web page is displayed, you are on the right path. The top line displays the time when statistics were updated. It probably reads ‘Never updated’. It is all right, you just have to manually run the first update.

Back in the Terminal, type the following command to initialize Awstats:
perl /usr/lib/cgi-bin/awstats.pl -config=mysite.com -update

When the statistics data has been initialized, Awstats displays the number of lines it found as qualified records, blank records, and other information.

Re-check the statistics page in your web browser:
http://mysite.com/cgi-bin/awstats.pl

If statistics figures and ip addresses are displayed on the page, the basic installation is done. It is, however, quite likely that you have to configure Awstats a little bit more so that it automatically runs in the background, and you may want to allow access to authorized people only. Read on for further instructions.

Configure Awstats to automatically update the statistics

During installation, Awstats sets an interval how often it automatically updates the statistics. However, extra tweaks are required to make it work.

From data in log file "/var/log/apache2/access.log"…
Error: Couldn't open server log file "/var/log/apache2/access.log" : Permission denied

If you see error messages telling that Awstats doesn’t have permission to access apache2 log file, check the access rights in the system for log files. Awstats update process runs in the background as user www-data that needs read access to the Apache log files.

Problems with access rights can be tricky to solve. Here is an article for further instructions.

Display country names instead of IP addresses in Awstats

The following software packages must be installed for the country resolution function (Geoip) to work in Awstats:
apt-get install libgeo-ip-perl
apt-get install libgeo-ipfree-perl

It takes a little time to download because a large table with country names and ip addresses is downloaded.

Edit the Awstats configuration file /etc/awstats/awstats.mysite.com.conf
Makes sure the following line is uncommented:
LoadPlugin="geoipfree"
Save the file and restart Apache:
systemctl restart apache2

If Awstats doesn't count all pages

If you suspect Awstats is not tallying up all your pages, and your site's URL structure is something like https://mysite.com/?p=3021, you have to change the default settings. The link structure is common, for instance, in default Wordpress installations. Open the Awstats configuration file /etc/awstats/awstats.mysite.com.conf. Find the line:

URLWithQuery=

The default value is 0, which explains why Awstats doesn't recognize that p=3021 is a page id. Change the URLWithQuery value to 1, and the pages will be included in the statistics. If your site has more complex URL structure, Awstats has more settings to tweak.

Protect your statistics with a password

The statistic information collected by Awstats is available to the entire digital world if you don’t prevent public access to it. A basic, simple way of restricting access is to set up a http password.

Edit the apache2 configuration file /etc/apache2/sites-available/mysite.conf.

AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
AuthType Basic
AuthName " Hello! "
AuthUserFile /usr/lib/cgi-bin/.htpasswd
Require valid-user
Order allow,deny
Allow from all

Apache must be restarted:
systemctl restart apache2

If you don’t already have a Linux password that can be used for this purpose, the command htpasswd can do it for you. For instance:
htpasswd -cb /usr/lib/cgi-bin/.htpasswd username password
The ‘username' and ‘password' should be set something not too easy to guess.

That's it for the Awstats configuration. Comparing statistics that draw their data from different sources, such as from web server log files and from visitor data available inside an CMS, has proven to be valuable for our admins.

One more thing: how to configure Awstats for multiple virtual hosts

Here are your questions answered for setting up Awstats to collect statistics for multiple virtual hosts (web sites) that are managed by one Apache server.

News

2026-08-08 12:47:00

Are there any statistics to prove my notion that new charging stations are popping up in Europe like mushrooms in the autumn? Sure, #EV #charging #roadtrip #Europe .https://klaava.com/charging-an-ev-on-a-road-trip-in-europe/


A village was left below the water when a dam was built here

2026-08-06 13:45:39

A village was left below the water when a dam was built here


News

2026-08-05 14:24:00

The world's first smartphone was available six years before the iPhone.https://www.digitalcameraworld.com/tech/phones/travel-back-to-2001-and-the-dawn-of-the-camera-phone


News

2026-07-29 10:24:00

Designers and eyewear companies are creating “anti-facial recognition” glasses in response to growing interest from customers who want to limit AI #camera biometric tracking and prevent facial recognition software from collecting their data. #privacy .https://petapixel.com/2026/07/23/these-anti-facial-recognition-glasses-block-surveillance-cameras/


News

2026-07-24 09:06:00

The biggest difference comes when you look at what you “own” and what is “protected.” In other words, when you upload your work on these portals, you share your license to use these photos in a number of ways. #photography #copyright .https://www.thephoblographer.com/2026/07/23/does-any-social-media-platform-actually-protect-your-photos/


News

2026-07-22 12:42:00

For the rest of us who like to enjoy good food and wine while traveling in #Europe we have the ranking of top 7 cities for food, and the best wine regions as assessed in 2026. #travel #food #wine .https://klaava.com/the-best-cities-in-europe-for-enjoying-food-and-wine/


Las Medulas mountain in Ponferrada, Spain has sharp teeth.

2026-07-20 11:08:46

arihak

Las Medulas mountain in Ponferrada, Spain has sharp teeth.


News

2026-06-21 08:01:00

When Icelandair launched a competition to find "a really bad #photographer", you might have rolled your eyes. But having looked through the winning pictures from Blanche Mortemard's portfolio, I think we can actually learn something.https://www.digitalcameraworld.com/photography/awards-and-competitions/shot-by-winner-of-worst-photographer-contest-what-these-travel-pictures-actually-prove-is-that-good-photography-isnt-the-same-as-technical-skill


Why not? A cafe inside a roundabout. Vilnius, Lithuania.

2026-06-15 11:30:30

arihak

Why not? A cafe inside a roundabout. Vilnius, Lithuania.


News

2026-06-07 14:24:00

Camera technology has come a long way in 96 years – but the subject, moment and composition of these World Cup photographs haven’t aged a day. #photographyhttps://www.digitalcameraworld.com/photography/sports-photography/these-photos-of-the-very-first-fifa-world-cup-final-are-surprisingly-good-considering-they-were-taken-on-100-year-old-cameras


Interesting shop, but probably won't be open any time soon. #antiques #France

2026-05-24 15:13:05

arihak

Interesting shop, but probably won't be open any time soon.#antiques#France


News

2026-05-19 18:43:00

The #EU Passenger Package proposal aims at allowing travelers to book a single ticket for a cross-border #train journey that may include multiple rail operators. .https://klaava.com/major-improvement-for-train-passengers-planned-in-europe-single-tickets-for-cross-border-travel/


Going down. #roadrip .

2026-05-11 17:28:53

arihak

Going down.#roadrip .


News

2026-04-29 10:04:00

Long, heavy trucks sped across villages faster than any Tesla or Toyota driver would dare. Dangerous speeding on highways and national roads was frequent. At times, it seemed that traffic rules didn’t exist in ... #roadtrip #Europe .https://klaava.com/the-safest-countries-for-a-road-trip-in-europe/


Fallas in Valencia.

2026-04-22 12:55:41

Fallas in Valencia.


Guarding the house.

2026-04-17 17:22:03

arihak

Guarding the house.


News

2026-04-12 09:11:00

Cable stickers are doing a perfect job. #ev .https://klaava.com/stealing-electric-vehicle-charging-cables-is-a-thing/


but who knows

2026-04-05 17:33:41

but who knows


Watch out, little guys! You'll get wet feet soon.

2026-03-31 12:58:37

arihak

Watch out, little guys! You'll get wet feet soon.


News

2026-03-25 15:00:00

It has been evident for a few years already that residents in cities like Venice or Barcelona have had enough of the ever growing numbers of tourists that conquer their streets and cafes, and who may not respect local customs. Do #tourism statistics support this? #travelhttps://klaava.com/these-cities-in-europe-attract-so-many-tourists-that-they-may-outnumber-inhabitants-during-peak-seasons/


More articles:
2017   2018   2019   2020   2021
2022   2023   2024