Webalizer
In this increasingly competitive digital era, website traffic monitoring is a crucial step in understanding visitor behavior and improving site performance. One lightweight, fast, and efficient web statistics tool is Webalizer. This guide will thoroughly review how to configure Webalizer on the Apache Web Server AlmaLinux 8 from scratch to publicly accessible, complete with security adjustments and optimizations for production use.
Webalizer is an open-source application used to analyze a domain's access log files on a web server and generate statistical reports in easy-to-read HTML format. Webalizer is widely used due to:
- Fast performance
- Easy-to-understand graphical output
- Support for various log file types
- Easy integration with Apache
Prerequisites
- Full
root
access - Basic Linux Command Line
- Security
- Apache/HTTPD installed
- Domain (optional)
- Timezone configured
Install Webalizer
Webalizer is generally available in the EPEL repository. Please run the following commands to update the server and install EPEL:
dnf update -y
dnf install epel-release -y
Run the following command to install the Webalizer package:
dnf install webalizer
Verify installation:
webalizer -v
Output example:
Webalizer V2.23-08 (Linux 4.18.0-553.58.1.el8_10.x86_64 x86_64) English
Copyright 1997-2013 by Bradford L. Barrett
Virtualhost for Webalizer
When managing multiple websites on a single server using Apache VirtualHost, it's ideal to have Webalizer statistics separated by domain. This provides clearer and more detailed visibility into each website's performance.
Make sure Apache is installed. If not, run the following command:
dnf install httpd -y
systemctl enable --now httpd
Make sure HTTP and HTTPS ports are open on firewalld when using it:
firewall-cmd --permanent --add-service={http,https}
firewall-cmd --reload
Each VirtualHost must have its own log file. Here's an example VirtualHost configuration for focusnic.biz.id
; you can customize it to suit your domain:
nano /etc/httpd/conf.d/focusnic.biz.id.conf
Fill in the default virtualhost parameters and also the parameters required for Webalizer:
<VirtualHost *:80>
ServerAdmin webmaster@focusnic.biz.id
ServerName focusnic.biz.id
ServerAlias www.focusnic.biz.id
DocumentRoot /var/www/focusnic.biz.id/public_html
Alias /web-stats "/var/www/focusnic.biz.id/webalizer"
<Directory "/var/www/focusnic.biz.id/webalizer">
AuthType Basic
AuthName "Webalizer Protected"
AuthUserFile "/etc/httpd/.htpasswd-focusnic"
Require valid-user
AllowOverride None
</Directory>
ErrorLog /var/log/httpd/focusnic.biz.id-error.log
CustomLog /var/log/httpd/focusnic.biz.id-access.log combined
</VirtualHost>
Create a user and password admin
to access the Webalizer page:
htpasswd -c /etc/httpd/.htpasswd admin
Then create a directory for the virtualhost above:
mkdir -p /var/www/focusnic.biz.id/public_html
Then restart Apache after making the changes:
apachectl configtest
systemctl restart httpd
Webalizer Configuration
Copy the default Webalizer configuration file per domain and customize it to suit the domain you want to monitor:
cp /etc/webalizer.conf /etc/webalizer.focusnic.biz.id.conf
Then edit the Webalizer file according to the domain above:
nano /etc/webalizer.focusnic.biz.id.conf
Adjust the following parameters:
LogFile /var/log/httpd/focusnic.biz.id-access.log
OutputDir /var/www/focusnic.biz.id/webalizer
HistoryName /var/lib/webalizer/focusnic.biz.id.hist
HostName focusnic.biz.id
Incremental yes
Then create a directory to store the logs generated by Webalizer:
mkdir /var/www/focusnic.biz.id/webalizer
Run the following command to generate logs from Webalizer:
/usr/bin/webalizer -c /etc/webalizer.focusnic.biz.id.conf
Then access http://$DOMAIN_NAME/web-stats
and enter the previously created authentication username and password:
Webalizer Automation
Unlike AWStats, which has the awstats_updateall.pl
script to automatically process all domains, Webalizer doesn't have a similar built-in script. However, we can replicate this concept in Webalizer by creating a simple shell script to automatically update all our Webalizer domains/configurations.
nano /root/webalizer_updateall.sh
Fill in the following script:
#!/bin/bash
CONFIG_DIR="/etc/webalizer"
for conf in "$CONFIG_DIR"*.conf; do
echo "Running Webalizer for: $conf"
/usr/bin/webalizer -c "$conf"
done
Give permission then test:
chmod +x /root/webalizer_updateall.sh
./webalizer_updateall.sh
Output example:
Running Webalizer for: /etc/webalizer.conf
Running Webalizer for: /etc/webalizer.focusnic.biz.id.conf
Then create a cron to generate Webalizer every day at 00:00
crontab -e
Fill in the following parameters:
0 0 * * * /root/webalizer_updateall.sh
Troubleshooting
- No Statistics Displayed
- Ensure the
access_log
log file is not empty - Check that the log format matches Webalizer's recognition
- Check the Apache user's read permissions for the log file
- The
web-stats
directory cannot be accessed
- Make sure the
/web-stats
directory has been created and allowed on the VirtualHost. - Check the Apache error log to determine the cause.
- Statistics Don't Update Automatically
Run the cron script manually for debugging:
./webalizer_updateall.sh
Check if Incremental yes
is enabled in Webalizer's .conf
.
- Mixed Statistics Across Domains
- Ensure each domain has a completely separate
.conf
log file and configuration. - Do not use the global
access_log
log file for all domains if you want statistics per VirtualHost.
Conclusion
Webalizer Configuration on Apache Web Server AlmaLinux 8 is a lightweight solution for monitoring website statistics in real time without relying on third-party services. With its quick installation and minimal resource usage, Webalizer remains a favorite among many sysadmins for standalone servers. The combination of Apache and Webalizer ensures that web traffic information can be monitored efficiently and measurably.
Q: Can Webalizer display real-time statistics?
A: No. Webalizer generates static, log-based reports. Updates only occur when Webalizer is restarted.
Q: Does Webalizer support HTTPS?
A: Yes. Webalizer works based on Apache logs, so all requests, including HTTPS, are logged and then processed by Webalizer.
Q: What's the difference between Incremental yes
and no
in Webalizer?
A:
yes
: processes only new log lines since the last run.no
: reprocesses the entire log from scratch (slower and more resource-intensive).
Q: Can Webalizer and AWStats be combined on a single server?
A: Yes. As long as they use different configuration files and output directories, there will be no conflicts.
Q: Can Webalizer be accessed without logging in?
A: Yes, but not recommended for production. We recommend using htpasswd
authentication to protect statistics data from the public.
Q: Is Webalizer suitable for websites with high traffic?
A: Webalizer is very fast, but it doesn't have the analytical flexibility of Google Analytics or Matomo. For high traffic, it can be used as a lightweight secondary analytics tool on the server side.
Q: How do I reset Webalizer statistics data?
A: Delete the contents of the output directory and the webalizer.current
file.
rm -rf /var/www/focusnic.biz.id/webalizer/*
rm -f /var/lib/webalizer/webalizer.current
webalizer