How to add an “update now” button in AWStats in cPanel

  John Mwaniki /    Updated on 07 Jul 2024

Awstats is an open-source Web analytics reporting tool. It comes packaged with your web hosting account cPanel and you can use it to track and monitor your website traffic.

In the previous article, I covered how to check your website traffic in cPanel using Awstats.

By default, Awstats updates the traffic statistics records once a day. That means for example if the records are updated in the morning, and you go checking in the evening, you won't be able to view the number of people that have visited your website that day. You have to wait and check the following day in the morning.

cPanel Awstats last updated

The good thing is that Awstats allows you to make some changes to its configurations, and be able to update the traffic statistics to the current time manually.

How to add an "Update Now" button in Awstats

Step 1: Log in to your cPanel

Step 2: Open "File Manager" under the Files section

cPanel File Manager

Step 3: Open the "tmp" folder

cPanel File Manager tmp folder

Step 4: Open the "awstats" folder

cPanel File Manager awstats folder

Step 5: Right-click on the file with the name "awstats.yourdomain.conf" then select the edit option. If an SSL certificate is installed on your website and the traffic has been redirected to the SSL version, you will see a folder named "SSL". Open it and edit the awstats.yourdomain.conf in it instead.

cPanel  awstats configuration file

Scroll down in the file and locate the line AllowToUpdateStatsFromBrowser=0 as shown below. Edit that line and replace 0 with 1. Click the save button in the top-right corner and close the file.

Edit cPanel  awstats configuration file

Now the configuration is complete and it should work.

Open the Awstats again and select the respective domain name whose configuration file has been edited (SSL, Non-SSL version, or subdomains).

You should be able to see an "Update Now" link at the top as shown below which when clicked loads the current statistics.

cPanel Awstats update now button

By default, cPanel updates the "awstats.yourdomain.conf" file daily when updating the traffic stats. This restores the value of AllowToUpdateStatsFromBrowser back to 0 and the button disappears.

This poses a challenge as you have to keep editing the configuration file daily back to 1 in order to view the "Update Now" button.

Luckily, there is a solution to that. After editing the Awstats config file and saving the changes, change the permission of that file to 444. cPanel won't make changes to it again and the "Update Now" button will remain to be visible forever.