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!
- 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.
- 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
- 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
- Download the latest build from – https://awstats.sourceforge.io/, for this tutorial version 7.7 was used.
- Open the zip file that downloaded from the awstats website.
- The zip will consist of a few folders and a file.
- docs (Folder)
- tools (Folder)
- wwwroot (Folder)
- README.md (File)
- Open the wwwroot folder.
- Extract the js, css and icon folders to your XAMPP or your WAMPP root directory.
- If your using XAMPP, the root directory will be located in C:/XAMPP_WAMPP_INSTALL_DIRECTORY/htdocs/
- If your using XAMPP, the root directory will be located in C:/XAMPP_WAMPP_INSTALL_DIRECTORY/www/
- Find and open the cgi-bin folder located in the XAMPP or WAMPP install directory, for example C:/XAMPP_WAMPP_INSTALL_DIRECTORY
- Create a new folder called ‘awstats’.
- Open the new awstats folder and create another folder called cgi-bin.
- 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
- Go back to the zip file and drag the full classes folder to sit inside the new awstats/cgi-bin folder.
- Within the awstats\cgi-bin folder rename the awstats.model.conf to awstats.conf.
- Then go ahead and open the awstats.conf file in a text editor.
- Change the following lines
- LogFile=”/var/log/httpd/mylog.log” to LogFile=”C:/XAMPP_WAMPP_INSTALL_DIRECTORY/apache/logs/access.log”
- DirCgi=”/cgi-bin ” to DirCgi=”/cgi-bin/awstats”
- SiteDomain=”” to SiteDomain=”localhost” (Or your actual site url, eg: SiteDomain=”www.example.com”)
- Save and close the awstats.conf file.
- Within the awstats/cgi-bin folder, open the awstats.pl in a text editor.
- Change the first line #!/usr/bin/perl to #!C:/XAMPP_WAMPP_INSTALL_DIRECTORY/perl/bin/perl.exe
- Save and close the awstats.pl file.
- Go to C:/XAMPP_WAMPP_INSTALL_DIRECTORY/apache/conf and open httpd.conf in a text editor.
- Add the following to the bottom of the file and save it.
- Locate your apache httpd.conf file, it will be under C:/XAMPP_WAMPP_INSTALL_DIRECTORY/apache/conf
- 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>
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.
- 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.
- The command prompt will now be open.
- 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
- 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
- Make note of what you set the -config parameter as it is needed to be supplied in the URL for viewing the statistics.
- Perl should now be executing, this may take a long time, depending on how long your website has been live/in development.
- Once phase 1 and phase 2 have completed in the command prompt, you can go ahead and view the statistics.
- Firstly, make sure you’re web server is switched on.
- 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
- Aw Stats will be loaded successfully in the browser.
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.
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.