Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Tutorials»How to Setup AWStats (Apache Log Analyzer) on CentOS/RHEL and Fedora

    How to Setup AWStats (Apache Log Analyzer) on CentOS/RHEL and Fedora

    By RahulFebruary 7, 20233 Mins Read

    AWStats is a free and open-source log analyzer that provides detailed insights into the traffic of your Apache web server. With AWStats, you can track website visits, referring websites, search engines, operating systems, browsers, and much more. It’s an effective tool for website owners, system administrators, and developers to monitor the performance of their website and make informed decisions to optimize it.

    Advertisement

    This article provides a step-by-step guide on how to set up AWStats on CentOS, RHEL, and Fedora systems. The guide covers all the necessary prerequisites, including installing the required dependencies and the AWStats software, configuring AWStats to analyze Apache logs, setting up Apache to work with AWStats, and updating the AWStats database to analyze Apache logs.

    By the end of this article, you’ll have a full understanding of how to install and set up AWStats on your Linux system and start analyzing your Apache logs to get valuable insights into your website’s traffic.

    Prerequisites

    • A VPS or dedicated server with a Linux operating system installed.
    • Apache web server installed and configured.
    • Perl and other required dependencies installed.

    Step 1: Installing AWStats

    To install AWStats on your system, follow these steps:

    1. Connect to your server via SSH
    2. Install the required dependencies using the following command:
      sudo dnf install perl-Time-HiRes perl-libwww-perl 
      
    3. Download the latest version of AWStats using the following command:
      wget https://downloads.sourceforge.net/awstats/awstats-7.9.tar.gz 
      
    4. Extract the downloaded archive using the following command:
      tar xvzf awstats-7.9.tar.gz 
      
    5. Move the extracted folder to the Apache web server’s root directory:
      mv awstats-7.9 /var/www/html/awstats 
      

    Step 2: Configuring AWStats

    Once AWStats is installed, you need to configure it to analyze your Apache logs. Here’s how:

    1. Copy the example configuration file to a new file:
      mkdir /etc/awstats 
      cp /var/www/html/awstats/wwwroot/cgi-bin/awstats.model.conf /etc/awstats/awstats.example.com.conf 
      

      Replace “example.com” in the above command with the name of your domain.

    2. Edit the newly created configuration file using your preferred text editor:
      nano /etc/awstats/awstats.example.com.conf 
      

      Modify the following variables in the configuration file:

      • LogFile: The path to your Apache log file. (/var/log/httpd/access.log)
      • SiteDomain: The domain name of your website. (example.com)
      • DirData: The directory where AWStats will store its data.
    3. Save the changes and close the text editor.

    Step 3: Setting Up Apache

    To set up Apache to work with AWStats, follow these steps:

    1. Create a new Apache virtual host file:
      nano /etc/httpd/conf.d/awstats.example.com.conf 
      

      Replace “example.com” in the above command with the name of your domain.

    2. Add the following code to the virtual host file:

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      <VirtualHost *:80>
        ServerName awstats.example.com
        DocumentRoot /var/www/html/awstats/wwwroot
        ScriptAlias /awstats/ /var/www/html/awstats/wwwroot/cgi-bin/
        <Directory /var/www/html/awstats/wwwroot/cgi-bin/>
          Options ExecCGI
          AllowOverride None
          Order allow,deny
          Allow from all
        </Directory>
        <Directory /var/www/html/awstats/wwwroot/>
          Options None
          AllowOverride None
          Order allow,deny
          Allow from all
        </Directory>
      </VirtualHost>

    3. Save the changes and close the text editor.

    Step 4: Analyzing Apache Logs

    To analyze your Apache logs with AWStats, follow these steps:

    1. Run the following command to update the AWStats database:
      cd /var/www/html/awstats/ 
      perl tools/awstats_updateall.pl now -config=example.com -awstatsprog=./wwwroot/cgi-bin/awstats.pl 
      

      Replace “example.com” in the above command with the name of your domain.

    2. Access the AWStats dashboard by visiting “http://awstats.example.com/awstats/awstats.pl?config=example.com” in your web browser.
    3. You should now see the AWStats dashboard displaying valuable insights into your website’s traffic, including the number of visitors, pages viewed, referring websites, and more.
    How to Setup AWStats on CentOS/RHEL and Fedora
    Awstats

    Step 5: Schedule to auto update

    Schedule a cron job to regularly update the AWStats database using newly created log entries. Add a new cron job in crontab like below. Read examples of cron scheduling

    1
    2
    ## Cron to update logs every day
    0 2 * * * cd /var/www/html/awstats/ && perl tools/awstats_updateall.pl now -config=example.com -awstatsprog=./wwwroot/cgi-bin/awstats.pl

    Conclusion

    In this article, we showed you how to install and set up AWStats on CentOS, RHEL, and Fedora systems. With this powerful log analyzer tool, you can gain valuable insights into your website’s traffic and make informed decisions to improve your website’s performance.

    Apache Log Analyzer awstats awstats installation setup awstats
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    What are the difference between SH and BASH

    What are the difference between SH and BASH?

    Understanding the Zombie Processes in Linux

    A Comprehensive Guide to Shutting Down or Rebooting Linux System

    View 15 Comments

    15 Comments

    1. SDB on April 25, 2019 11:26 am

      I am getting below error while trying to access awstats url from browser.
      Invalid file path. Please check the correct URL.
      Please help.

      Reply
    2. Ross on March 7, 2018 11:18 am

      Also Please update about
      How to enable username and password for access the awstat report

      Thanks

      Reply
      • Kiosk on March 10, 2018 7:00 am

        Hi ,

        The same Question i also have . Very simple and good article .BUt importantly we have to secure .Please share how to setup user name and password for Awstat

        Thanks

        Reply
    3. ThomasCync on April 18, 2016 1:07 pm

      Howdy, nice web site you’ve in here.

      Reply
    4. Pankaj on August 12, 2015 10:06 am

      Hi,

      Please could you guide, How to configure Awstats with Nginx.

      I have configure all with Niginx, but unable to view it on browser, Am sure there would be a perl base configuration required for same.

      Please advice.

      Reply
    5. Hunky on June 10, 2015 8:40 am

      How to do this same thing on a server which is running multiple domain under one shared IP address ??

      How to configure AwStats for each domain ??

      Would be great if you please update the tutorial for the same..

      Reply
    6. Shankar Patel on June 4, 2015 5:43 pm

      Good article. Saved my time.

      Reply
    7. chris on June 19, 2014 6:06 am

      Awesome Blog. I followed the steps, it is working on my site now,thanks

      Reply
    8. djitri2000 on April 24, 2014 5:46 pm

      Hi.
      the bellow command bug whith centos 6.5

      crontab -l 0 2 * * * /usr/bin/perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=tecadmin.net -update

      crontab : option invalide — ‘c’
      crontab: usage error: unrecognized option

      Reply
    9. Malissa on October 6, 2013 5:20 pm

      Very good info. Lucky me I discovered your website by accident (stumbleupon).
      I’ve bookmarked it for later!

      Reply
    10. carter cole on July 1, 2013 5:16 pm

      your stupid plugin that spams the clipboard on copy is snipping the text so i cant copy and paste the config file… very annoying at least let the whole thing get copied

      Reply
      • xnxx on May 2, 2015 1:30 pm

        Try using nano instead of vim when i was a noob it kinda pissed me off too..

        Great guide btw rahul 🙂

        Reply
    11. www.satellitecardsharing.com/dreamsharing/ on April 28, 2013 5:14 am

      Hey very interesting blog!

      Reply
    12. longchamp outlet on April 24, 2013 4:51 am

      Awesome Blog. I add this Post to my bookmarks.

      Reply
    13. Daniel on April 16, 2013 3:12 pm

      nice article, very well written….

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Setting and Getting the Default Timezone in Python
    • What is Media Access Control (MAC) Address?
    • What is Cross-Site Scripting (XSS)?
    • What is Content Security Policy (CSP)?
    • A User’s Guide to Understanding Redirection Operators in Bash
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.