• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 23, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Fedora

How to Install AWStats on Fedora 28

How VPS by How VPS
December 1, 2019
in Fedora
0
How to Install and Use ‘yum-utils’ to Maintain Yum and Boost its Performance
0
SHARES
63
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Installing AWStats and tools
  2. Configuring AWStats for your site
  3. Setting up permissions
  4. Run AWStats for the first time
  5. Configuring Nginx to view AWStats online
  6. Securing AWStats
  7. Running AWStats daily and when logs are rotated
  8. Want to contribute?


AWStats is a useful tool for analyzing web traffic. Its HTML interface can be accessed through the browser, giving you easy insights about who is viewing your website. This tutorial will walk you through installing, configuring, and securing AWStats for an Nginx web server on Fedora 28.

If you haven’t installed Nginx yet, do so now:

sudo dnf install nginx
sudo systemctl enable --now nginx

Installing AWStats and tools

First, you’ll need to install a few things. Fortunately, this is very easy, as all the software you’ll need is in Fedora’s repositories:

sudo dnf install awstats httpd-tools php-fpm

httpd-tools is a package containing some tools we’ll need, such as htpasswd. It was designed for use with Apache, but most of the tools also work with Nginx. The other tool, php-fpm, allows us to run PHP scripts from Nginx.

We’ll need to enable php-fpm through systemctl:

sudo systemctl enable --now php-fpm

Configuring AWStats for your site

We’ll need to configure AWStats before we can use it. Copy the model config file to create a new configuration for your site:

sudo cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.<yoursitename>.conf

Now edit that file:

sudoedit /etc/awstats/awstats.<yoursitename>.conf

Scroll down to the line that says LogFile="/var/log/httpd/access_log". Because we’re using Nginx instead of Apache, we need to change this. Change it to LogFile="/var/log/nginx/access.log".

Next, scroll down all the way to the line that says DirIcons="/awstatsicons". If you can’t find it, type /DirIcons, then press ENTER to jump to it. Change this line to DirIcons="../icon".

Finally, AWStats needs to know what website it’s analyzing. This way it can report things such as which users are coming from external sites. The two relevant configuration options here are SiteDomain and HostAliases. SiteDomain will simply be the domain name of the site; and HostAliases will be a list of any other domain names that might be used (for example, if your site is www.example.com, you might put example.com here if it is the same site).

All of the configuration options are documented in the config file. If you want to know exactly what an option does, or if you want to see all the options that AWStats has to offer, just read the comments in that file.

Setting up permissions

It is strongly recommended not to run AWStats as the root user. We’ll run AWStats under the nginx user that has already been set up during the Nginx installation.

To do this, we’ll need to make nginx the owner of the directory where AWStats stores its database (/var/lib/awstats):

sudo chown -R nginx /var/lib/awstats

Run AWStats for the first time

In a later step, we’ll set up AWStats to run when the server logs are rotated. This first time, however, it’s best to run it manually. Do that with the following command:

sudo -u nginx /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=<yoursitename>

Note: The -u nginx part tells sudo to run the command as the nginx user rather than as root.

The output will be similar to the following:

Create/Update database for config "/etc/awstats/awstats.<yoursitename>.conf" by AWStats version 7.7 (build 20180105)
From data in log file "/var/log/nginx/access.log"...
Phase 1: First bypass old records, searching new record...
Direct access after last parsed record (after line 0)
Jumped lines in file: 0
 Found 0 already parsed records.
Parsed lines in file: 0
 Found 0 dropped records,
 Found 0 comments,
 Found 0 blank records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 0 new qualified records.

Configuring Nginx to view AWStats online

Next, we’ll configure Nginx so we can view our website statistics from the website itself, rather than through a command-line interface. Edit your main Nginx configuration file:

sudoedit /etc/nginx/nginx.conf

Here, we’ll add a folder to contain the AWStats section of the website. In this tutorial, we’ll call it webstats, but you can call it whatever you want.

Find the section of the config file that says server. After the line include /etc/nginx/default.d/*.conf;. Add a new section:

location /webstats/ {
    alias /usr/share/awstats/wwwroot/;

    location ~ /cgi-bin/(.+/.pl) {
        include fastcgi.conf;
        fastcgi_pass php-fpm;
        fastcgi_split_path_info ^/webstats/(.+/.pl)(.*)$;
        fastcgi_param SCRIPT_FILENAME /usr/share/awstats/tools/nginx/awstats-fcgi.php;
        fastcgi_param X_SCRIPT_FILENAME /usr/share/awstats/wwwroot/$fastcgi_script_name;
        fastcgi_param X_SCRIPT_NAME $fastcgi_script_name;
    }
}

This section tells Nginx that when we go to the webstats directory in our browser, it should serve AWStats’s web root, and if we ask for a script in the cgi-bin directory, it should run it.

After editing the config file, we need to restart Nginx:

sudo systemctl restart nginx

Now open your browser and go to <your website>/webstats/cgi-bin/awstats.pl?config=<yoursitename>. This is AWStats’ homepage for your website. It will look somewhat like this:

How to Install AWStats on Fedora 28

Make sure the page loads correctly and that you can see the AWStats logo in the top right corner. If the page doesn’t load or the logo is missing, you may have something misconfigured in a previous step — go back and make sure all the paths are correct.

Securing AWStats

Failing to secure your statistics page can lead to bad things, such as referrer spam. Also, you don’t want your detailed analytics data exposed to the entire Internet.

We’ll use Nginx to put a password on the statistics page. Open /etc/nginx/nginx.conf again, go back to the section you added, and add the following lines under location /webstats/ {:

auth_basic "Username and password required to access AWStats";
auth_basic_user_file /etc/nginx/.htpasswd;

Now we need to create that .htpasswd file. Exit the config file and run the following command:

sudo htpasswd -c /etc/nginx/.htpasswd <username>

Your username can be mostly anything, but it shouldn’t contain spaces and should be unique, not something easy to guess like admin or webmaster. When you run the command, you’ll be prompted for a password. Enter a secure password, then confirm it.

Reload Nginx:

sudo systemctl restart nginx

Try to access AWStats again. This time, you will be asked for your username and password. Enter them and you will be sent to the AWStats homepage as before.

Running AWStats daily and when logs are rotated

Finally, we need our statistics to update. We’ll use cron for that. It’s a task scheduler utility, and it’s preinstalled on Fedora (and most other Linux distributions). We’ll have it run AWStats every day at midnight. Edit /etc/crontab and add the following line at the bottom:

0 0 * * * nginx /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=<yoursitename>

To avoid losing data, we’ll also want AWStats to run when the logs are rotated. To do that, edit /etc/logrotate.d/nginx. Above the postrotate section, add the following:

prerotate
    /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=<yoursitename>
endscript

AWStats is now all set up and ready to go.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

How to Install Lychee 3.1 Photo Album on a Fedora 26 LAMP VPS

Next Post

How to Install MyBB on Fedora 28

Next Post

How to Install MyBB on Fedora 28

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet