Follow Us on Google+
Follow Us on Twitter
Like us on Facebook
Subscribe to our RSS Feed

How To Access AwStats Outside cPanel

How To Access AwStats Outside cPanel
Posted by on May 16, 2008 in Tutorials. Last modified on May 15, 2013.
 

AwStats is my favorite web statistics tool. For cPanel users, there’s no installation needed, AwStats is already installed. But there are times when you want some people to access their website’s statistics but you don’t necessarily want to give them access to cPanel.

This tutorial will show you how you can make AwStats accessible outside cPanel.

  1. Get yourself a copy of AwStats from http://awstats.sourceforge.net. The latest version available at the time of this writing is AwStats 6.7.
  2. Extract the content from the archive to your hard drive.
  3. Using an FTP client, create a directory at the root of your website (ie.: /public_html) and name it “stats” (or whatever you’d like to call it). At this point your directory should be accessible like this: http://www.yourwebsite.com/stats
  4. Next upload the content from awstats-6.7\wwwroot\cgi-bin to your stats directory you’ve just created.
  5. Using your FTP client, change the file permissions on awredir.pl and awstats.pl to 755 so that anyone can execute these scripts.
  6. Still using FTP, download the AwStats configuration file created by cPanel to your computer. This file is usually located in /tmp/awstats/awstats.[your website].conf
  7. Upload this file back to your web hosting account in your /public_html/stats folder.
  8. Create a directory named images in /public_html (ie.: /public_html/images).
  9. Upload the AwStats icon folder (ie.: awstats-6.7/wwwroot/icon) to your images folder you’ve just created. Rename the icon folder to awstats (ie.: /public_html/images/awstats).

At this point, you should now be able to access AwStats with this URL: http://www.yourwebsite.com/stats/awstats.pl?config=yourwebsite.com

But we’re not over yet. We don’t want everybody to access our statistics!

  1. Log in cPanel and click on the Password Protect Directories icon. Browse to your public_html directory and select the stats folder.
  2. Check the Password protect this directory checkbox and enter a name for the protected directory (you can enter whatever you want, it doesn’t matter). Click on the Save button when done.
  3. You should get a confirmation message saying that the directory is now protected. Click the Go Back link.
  4. In the Create User section, enter the username and password you want to use to access AwStats and click on Add/modify authorized user.
  5. Now try to access AwStats (http://www.yourwebsite.com/stats/awstats.pl?config=yourwebsite.com) again to make sure it is protected.

Note for WordPress users: password-protecting a subdirectory will not work because of the redirections instructions in the .htaccess file at the root of your website. While it’s not impossible to make it work, it’s easier to create a subdomain for awstats (ie.: http://stats.yourwebsite.com).

Ok great we can now access AwStats outside cPanel. But we can make things even easier. How about accessing your stats at http://www.yourwebsite.com/stats and not having to specify the configuration file?

  1. Using Notepad, create a file named index.php on your computer and add the following content:
    <?php
    header('Location: http://www.yoursite.com/stats/awstats.pl?
    config=yoursite.com');
    ?>
  2. Upload this file in your stats folder (ie.: /public_html/stats)

Now try to open http://www.yourwebsite.com/stats with your web browser. You should now be prompted for a username and password. You will then be redirected automatically to your statistics page!

That’s it, you’re done!

 
Tags: awstats, cpanel, htaccess, password protect, statistics

About Stephane Brault

Stephane is a web developer and system administrator with over 18 years of experience. Specialized in PHP programming and Linux server administration, he also provided development and consulting services to SMBs for several years before becoming an online entrepreneur.

23 responses so far ↓

avatar

1. Response by : Jan on Jul 16, 2008 at 3:17 pm

This is the best and most straight-forward explanations on how to access AwStats outside of cPanel I’ve found on the Internet. Great job!

avatar

2. Response by : Ray Gauci on Nov 12, 2008 at 10:06 am

Worked like a charm.
I have an ADDON account on my hosting something like http://www.myaccount.com/client
The above does not work because I need to do the right pathto links, for example this works
/home/myaccount/public_html/stats/awstats.pl
but if I have another ADDON account like
/home/myaccount/public_html/client/stats/awstats.pl
it will give me an error
Can you lead me to edit the conf file to read ADDON accounts?

avatar

3. Response by : The Web Hosting Hero on Nov 12, 2008 at 10:12 am

Have a look into /tmp/awstats

All the awstats config files are there

avatar

4. Response by : Reports on Jan 17, 2009 at 4:35 am

Thanks. Its works. I tested it on my site.

avatar

5. Response by : Bryan - After5PC.net on Mar 4, 2009 at 10:18 am

Does this method also auto-update and in-sync with the one within the control panel as traffic continues? Or is the stats uploaded onto there just for that time?

Thanks for confirming! This is definitely useful.

avatar

6. Response by : The Web Hosting Hero on Mar 5, 2009 at 10:01 am

It will not auto-update unless you add a cron task but I’ve never tried this.

You’re going to have the possibility to update the stats manually though. Simply set the value of “AllowToUpdateStatsFromBrowser” to 1 in your AwStats config file.

avatar

7. Response by : MK on Jun 20, 2009 at 4:19 am

Very good tutorial . My only problem was , i can’t make it working as http://www.yourwebsite.com/stats . Only http://www.yourwebsite.com/stats/awstats.pl?config=yourwebsite.com works. When an index.php file is placed , it shows parse error .

avatar

8. Response by : best on Sep 22, 2010 at 9:49 am

You are the BEST. Your explanation is really good. Thanks , and thank you, internet :)

avatar

9. Response by : ice chocolate on Oct 17, 2010 at 11:07 pm

Very usefull and helpfull. this is exactly what i need for my client since i dont want them to access cpanel.
btw, i tried in some cpanel and all work but not in one, when i tried to access it, its just open a pop up small window to download the awstats.pl file. i really dont know why, i tried from the beginning for many times but still happened the same. do you have any ideas what happen with it?
also i found error in your code “” that should use single quote (‘) instead of double (“).

thanks again Hero adn look forward for your help

avatar

10. Response by : Michael on Nov 18, 2010 at 3:00 pm

I had a client ask if they could access the stats for their web site and like you noted top of your article I had concerns about giving them full access to their CPanel.

Your instructions and the follow up code correction and how to set manual updating have enabled me to provide this access without compromising the security of the main account.

Thank you for taking the time to create this guide.

Michael

avatar

11. Response by : Alex on Dec 13, 2010 at 7:33 pm

Prezados,

Tudo foi feito entretanto sem o index.php ele pergunta se quero fazer o download do awstats.pl. Criei então um index.php, a aparece que é necessário usar SSL para poder visualizar as infos e me redireciona ao cpanel. Podem me ajudar?

avatar

12. Response by : juan carlos on Jul 26, 2011 at 9:46 am

Hello, thanx for all the info, very helpfull. However i think that a custom install of awstats will be up to date with the one running inside cpanel, since it reads the same txt files, so a manual update is not necessary. I did this a couple of weeks ago on a domain and when i checked today i saw that the stats were updated 2 hours earlier. Also both instances of stats were displaying the exact same results. Correct me if i am wrong and any related information is more than welcome.

avatar

13. Response by : arif saiyad on Sep 12, 2011 at 10:54 am

For those how say that “index.php” doesnt work, or http://www.yourwebsite.com/stats doesnt work, just copy and paste the following code in a blank index.php file:

Upload it to Stats folder.

Your done!

avatar

14. Response by : arif saiyad on Sep 12, 2011 at 11:01 am

For those how say that “index.php” doesnt work, or http://www.yourwebsite.com/stats doesnt work, just copy and paste the following code in a blank index.php file:

IMPORTANT: Remove the # symbol in opening an closing tags.

Upload it to Stats folder.

Your done!

avatar

15. Response by : The Web Hosting Hero on Sep 12, 2011 at 11:04 am

@Arif: unfortunately WordPress strips off any PHP code from comments. Send it to info@thewebhostinghero.com and I’ll post it.

avatar

16. Response by : The Web Hosting Hero on Sep 12, 2011 at 11:28 am

@Arif: I’ve made the correction the post. Thank you for letting me know!

avatar

17. Response by : Sovann on Oct 13, 2011 at 10:45 pm

Hi,

For step : Upload the AwStats icon folder (ie.: awstats-6.7/wwwroot/icon) to your images folder you’ve just created. Rename the icon folder to awstats (ie.: /public_html/images/awstats).

are there any solution to upload it to another folder like this :
/public_html/report/images for display awstats report?

avatar

18. Response by : Jim Giedris on Nov 15, 2011 at 5:07 pm

Use this with your variables for yourusername, yourpassword, yoursite verify port

http://yourusername:yourpassword@www.yoursite.com:2082/awstats.pl?config=yoururl.com&ssl=&lang=en

avatar

19. Response by : jose on Jan 27, 2012 at 8:36 am

It’s about “not work at wordpress”. For WP you said that we should make a subdomain for Awstats. Well this is too complicated foe me, because my WP is installed at a subdomain. So should I make the subdomain of the subdomain???

avatar

20. Response by : Steve on Jun 5, 2012 at 3:51 am

thanks for the great tutorial.

However i think there is a little info missing –

doesnt the log file address reference in the conf file need to change?

avatar

21. Response by : Adam on Jul 2, 2012 at 1:14 am

When i opened url with
http://www.yoursite.com/awstats/awstats.pl?
config=yoursite.com

Its show me error about Page Not Found ??

What happened??? I dont know… Pls help me…

avatar

22. Response by : bob on Feb 2, 2013 at 5:10 pm

Is it safe to leave the folder without pasword protection?
Thank you

avatar

23. Response by : Stephane on Feb 4, 2013 at 8:59 am

@Bob: I don’t think it would be safe to do this. The tutorial shows how to protect the folder.

Leave a Comment




Bluehost
MaxCDN - Speed Up Your Website