Learn how to recalculate Plesk AWStats and update website stats for accurate reporting with all commands included in one guide. Our Plesk Support Team is always here to help you.

How to Recalculate Plesk AWStats for Accurate Website Statistics

Monitoring website traffic is essential for every website owner, and AWStats in Plesk provides detailed analytics. However, sometimes the default monthly statistics may not reflect the complete picture. That’s where plesk awstats recalculate comes in. Recalculating AWStats ensures that your website statistics are accurate and updated, allowing better insights into traffic trends.

In this guide, you will get direct instructions to recalculate AWStats for previous months, including all commands you need. No guesswork, just precise commands that work.

plesk awstats recalculate

Preparing the Environment for AWStats Recalculation

Before diving into recalculation, you need to set up the environment variables. Open your terminal and execute the following commands:

export vhost_name=<domain_name>
export AWSTATS_BIN_D=`grep ^AWSTATS_BIN_D /etc/psa/psa.conf | awk '{print $2}'`
export HTTPD_VHOSTS_D=`grep ^HTTPD_VHOSTS_D /etc/psa/psa.conf | awk '{print $2}'`
export PRODUCT_ROOT_D=`grep ^PRODUCT_ROOT_D /etc/psa/psa.conf | awk '{print $2}'`
export awstats=${AWSTATS_BIN_D}/awstats.pl
export awstats_gen_opts="-staticlinks -configdir=${PRODUCT_ROOT_D}/etc/awstats -config=${vhost_name}-http"

These commands define the necessary directories and files AWStats needs to access your domain logs and generate updated statistics.

Preparing Previous Statistics Files

Next, you need to archive old statistics files. Run:

find $HTTPD_VHOSTS_D/system/$vhost_name/statistics/webstat -name '*.txt' -exec mv '{}' '{}'.orig \;

This ensures old .txt files don’t interfere with the new calculation.

Analyzing Domain Log Files

Once the environment is ready, it’s time to process your domain log files:

$awstats $awstats_gen_opts -LogFile=$HTTPD_VHOSTS_D/system/${vhost_name}/statistics/logs/access_log.processed

This command generates subdirectories named YYYY-MM under:

$HTTPD_VHOSTS_D/system/<domain_name>/statistics/webstat

Each folder corresponds to the year and month of the logs.

If your recalculation spans multiple logs, process them starting from the oldest: access_log.processed.10, access_log.processed.9 … access_log.processed.1.

Creating Missing Directories

If any directories are missing for the period you want to recalculate, create them with:

for y in <year_first> <year_last> ; do
for m in `seq 1 12` ; do
mkdir ${HTTPD_VHOSTS_D}/system/${vhost_name}/statistics/webstat/$y-$(printf "%.2d" $m)
done
done

Replace <year_first> and <year_last> with the earliest and latest years of your logs.

Recalculate AWStats For Accurate Insights

Chat animation


Generating Updated Statistics Pages

Now, generate the statistics pages for each month and link the outputs:

for y in <year_first> <year_last> ; do \
for m in `seq 1 12` ; do \
dest_dir=$HTTPD_VHOSTS_D/system/$vhost_name/statistics/webstat/$y-$(printf "%.2d" $m) ; \
$awstats $awstats_gen_opts -month=$m -year=$y -output > $dest_dir/awstats.${vhost_name}-http.html ; \
ln -s $dest_dir/awstats.${vhost_name}-http.html $dest_dir/index.html ; \
for output in alldomains allhosts lasthosts unknownip allrobots lastrobots session urldetail urlentry urlexit osdetail unknownos refererse refererpages keyphrases keywords errors404 ; do \
$awstats $awstats_gen_opts -month=$m -year=$y -output=$output > $dest_dir/awstats.${vhost_name}-http.$output.html ; \
done ; \
done ; \
done

This will rebuild your website’s statistics for each month and prepare detailed reports.

Updating the Navigation Menu

Finally, update the upper frame navigation menu to reflect the recalculated months:

$PRODUCT_ROOT_D/admin/sbin/statistics --calculate-one --domain-name=$vhost_name

This ensures that the Plesk interface shows all the updated statistics for easy viewing.

[If needed, Our team is available 24/7 for additional assistance.]

Conclusion

Recalculating Plesk AWStats is essential when old statistics are incomplete or inaccurate. By following this guide, you can fully recalculate Plesk AWStats, keeping your website reports precise and reliable. The commands listed above cover every aspect from environment setup to generating monthly statistics, making your website analytics truly dependable.

Using plesk awstats recalculate correctly guarantees that your insights reflect real traffic patterns. Every site owner looking to maintain accurate reporting should adopt this approach without skipping a step.