There are over 10 stats packages installed in my server (AWStat, Webalizer, etc) and cPanel has an interface to show them in terms of visitors, bandwidth, popular pages, etc.

It is possible to access those stats through PHP?

Possible applications include getting a list of most popular content, reporting on visitors and taking actions depending on bandwidth, etc. I know that many of these features can be implemented by creating my own stats counting system but since that information is already somewhere, it could be awesome not to have to write more code to collect it.

  • This is half an answer. All those packages are using the same source for their data - the raw access logs - which you can get at using cPanel too. So if you search for "php access log analyzer" or variations (such as apache log) then that will give some possibilities. May 18, 2011 at 8:04

1 Answer 1


There's no official cPanel API to access detailed stats data. There are, however, a few scripted workarounds:

  1. There's a reference to scripting cPanel access to scrape AWStats output with PHP here.

  2. There are also GPL-licenced projects to access Apache/AWStats log data with PHP here (via access panel). The log exporter looks like it might be the more useful of the two in your case.

  3. There's some PHP code to display Webalizer stats without logging in to cPanel here and a method to make Webalizer stats public with htaccess here. (You'd then have to scrape data from the Webalizer html table, which is less than ideal.)

These solutions all feel a little hacked together, though. If you're building a custom control panel to display visitor stats, I'd suggest using Google Analytics with the official Analytics API, which provides read-only access to traffic data.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.