How to install Awstats with XAMPP or WAMPP on Windows

Installing AwStats with XAMPP or the WAMPP build can be quite tricky. The AwStats website doesn’t really clarify how to install it correctly on a windows machine. This is the exact reason this tutorial is being made. To save you the hassle of banging your head against the desk for hours on end!

Prerequisites

  • XAMPP/WAMPP must be installed, preferably to the C: Drive.
  • You must have a text editor installed to edit certain files. Try Netbeans, its free.

Important things to do and take note of before we start

Please read through the following two steps, it is vital for you to understand before configuring your development environment with this how-to-tutorial.

  1. At any time that ‘XAMPP_WAMPP_INSTALL_DIRECTORY’ is specified within this tutorial, it needs to be replaced with Your XAMPP or WAMPP install directory. For Example C:\XAMPP
  2. Add the PERL path variable to your computer (It may already be there after installing but just check in case). This will make it much easier when using command prompt, meaning you won’t have to specify explicit paths to the perl.exe.
    • Right Click My Computer -> Properties -> Advanced System Settings -> Environment Variables.
    • Find the PATH variable and click edit -> Add the full path to the perl.exe folder eg in my case – C:\xampp_\perl\bin If there is already values in here, separate the last value with a semi-colon EG: C:\appData;C:\xampp\perl\bin
    • If you can’t find a PATH Variable, then simply click new and create one – Variable Name must be PATH and the value must be the path to your perl.exe directory eg in my case C:\xampp\perl\bin

Configuring And Installing Awstats

    1. Download the latest build from – https://awstats.sourceforge.io/, for this tutorial version 7.7 was used.
    2. Open the zip file that downloaded from the awstats website.
    3. The zip will consist of a few folders and a file.
      1. docs (Folder)
      2. tools (Folder)
      3. wwwroot (Folder)
      4. README.md (File)
    4. Open the wwwroot folder.
    5. Extract the js, css and icon folders to your XAMPP or your WAMPP root directory.
      1. If your using XAMPP, the root directory will be located in C:/XAMPP_WAMPP_INSTALL_DIRECTORY/htdocs/
      2. If your using XAMPP, the root directory will be located in C:/XAMPP_WAMPP_INSTALL_DIRECTORY/www/
    6. Find and open the cgi-bin folder located in the XAMPP or WAMPP install directory, for example C:/XAMPP_WAMPP_INSTALL_DIRECTORY
    7. Create a new folder called ‘awstats’.
    8. Open the new awstats folder and create another folder called cgi-bin.
    9. Go back to the zip file and extract the contents of the cgi-bin to the new awstats/cgi-bin folder. The path will be something like the following C:/XAMPP_WAMPP_INSTALL_DIRECTORY/cgi-bin/awstats/cgi-bin
    10. Go back to the zip file and drag the full classes folder to sit inside the new awstats/cgi-bin folder.
    11. Within the awstats\cgi-bin folder rename the awstats.model.conf to awstats.conf.
    12. Then go ahead and open the awstats.conf file in a text editor.
    13. Change the following lines
      1. LogFile=”/var/log/httpd/mylog.log” to LogFile=”C:/XAMPP_WAMPP_INSTALL_DIRECTORY/apache/logs/access.log”
      2. DirCgi=”/cgi-bin ” to DirCgi=”/cgi-bin/awstats”
      3. SiteDomain=”” to SiteDomain=”localhost” (Or your actual site url, eg: SiteDomain=”www.example.com”)
    14. Save and close the awstats.conf file.
    15. Within the awstats/cgi-bin folder, open the awstats.pl in a text editor.
    16. Change the first line #!/usr/bin/perl to #!C:/XAMPP_WAMPP_INSTALL_DIRECTORY/perl/bin/perl.exe
    17. Save and close the awstats.pl file.
    18. Go to C:/XAMPP_WAMPP_INSTALL_DIRECTORY/apache/conf and open httpd.conf in a text editor.
    19. Add the following to the bottom of the file and save it.
    20. Locate your apache httpd.conf file, it will be under C:/XAMPP_WAMPP_INSTALL_DIRECTORY/apache/conf
    21. Open it with a text editor and paste the following settings to the bottom of the file and save.
# 
# Directives to add to your Apache conf file to allow use of AWStats as a CGI. 
# Note that path "/usr/local/awstats/" must reflect your AWStats Installation path. 
# 
Alias /awstatsclasses "C:/XAMPP_WAMPP_INSTALL_DIRECTORY/cgi-bin/awstats/classes/" 
Alias /awstatscss "C:/XAMPP_WAMPP_INSTALL_DIRECTORY/htdocs/css/" 
Alias /awstatsicons "C:/XAMPP_WAMPP_INSTALL_DIRECTORY/htdocs/icon/" 
ScriptAlias /awstats/ "C:/XAMPP_WAMPP_INSTALL_DIRECTORY/cgi-bin/awstats/cgi-bin/" 
# 
# This is to permit URL access to scripts/files in AWStats directory. 
# 
<Directory "C:/XAMPP_WAMPP_INSTALL_DIRECTORY/cgi-bin/awstats/cgi-bin/"> 
Options None 
AllowOverride None 
Order allow,deny 
Allow from all 
</Directory>

Executing AwStats

Now that all the configuration is setup for Apache and awstats to work together, we can now use perl to run the stats build and give us those informative statistics.

  1. Hit the windows key + R on the keyboard together and type cmd and hit enter. Or go to start and search for ‘run’ and open it, type cmd and hit enter.
  2. The command prompt will now be open.
  3. Type the following command (Replacing WWW_YOURHOST_COM with the SiteDomain you specified earlier, eg: localhost) – perl C:/XAMPP_WAMPP_INSTALL_DIRECTORY/cgi-bin/awstats/cgi-bin/awstats.pl -config=WWW_YOURHOST_COM –update
  4. If you got the error that perl wasn’t recognized, then you will need to explicitly reference it like the following C:/XAMPP_WAMPP_INSTALL_DIRECTORY/perl C:/XAMPP_WAMPP_INSTALL_DIRECTORY/cgi-bin/awstats/cgi-bin/awstats.pl -config=WWW_YOURHOST_COM –update
    1. Make note of what you set the -config parameter as it is needed to be supplied in the URL for viewing the statistics.
  5. Perl should now be executing, this may take a long time, depending on how long your website has been live/in development.
  6. Once phase 1 and phase 2 have completed in the command prompt, you can go ahead and view the statistics.
  7. Firstly, make sure you’re web server is switched on.
  8. Open a browser and type the following url – http://WWW_YOURHOST_COM/awstats/awstats.pl?config=WWW_YOURHOST_COM – In my case, the URL is http://localhost/awstats/awstats.pl?config=local
  9. Aw Stats will be loaded successfully in the browser.

Common Errors

If you get an error when navigating to your statistics data within the browser – For example, something along the lines of – couldn’t create child process: 720002: awstats.pl Go back to step 16 of the Configuring And Installing section and make sure that it has been changed properly.

If you get an object/file not found error, check the httpd.conf file within the Apache folder and make sure all the paths are parallel to your hard drives directories. Check out Steps 18 – 21 of the Configuring And Installing section again.

Summary

Interesting Links

Hopefully, this will save you some major wasted time. If you have any problems setting this up, feel free to leave a comment and I will get back to you.

How to install Awstats with XAMPP or WAMPP on Windows

You May Also Like

Leave a Reply

Your email address will not be published.