Gathering web server stats using PHP?

Soldato
Joined
12 Jan 2004
Posts
6,824
Location
Londinium
Hi guys,

Im hosted with tsohost and was wondering if anyone knows any good tutorials or info about getting web server stats with PHP?

The reason is because Ive set up a little online admin component for my site and want it to display certain stats on the home page such as total visits this week, etc.

Google doesnt turn up much besides the typical stats programs (webalyser, etc) so has anyone got any info here?

Cheers.
 
cPanel by default will allow you to download the raw access logs from Apache. You could set up a script to run regularly using a cron job, download the files from cPanel and process them. You should however check with tsohost that this is allowed as it could be very CPU intensive.

By far the best way to manage it, in my opinion, would be to log your own stats into a MySQL database when users hit various pages. You can then track their progress through your site, their browser, their IP (and country with an ip2country db) and so on.

May be a starting point

Good luck :).
 
Thanks for the info Adz. I didn't realise there would be so much work in gathering a few stats, I think this may be overkill for the few things that I wanted to display but I'll look into it anyway.

I wondered if there were some existing scripts that access standard web server logs and get you the info you want? I haven't been able to find any so I guess it's not that simply :(
 
Webstats are stored in /userdir/tmp so you can setup a cron job to copy the necessary files from tmp to the public_html/webstats (or similar) directory and from there you can see the web stats :)

You can then scrape the files with PHP to find out the bits you want, which is kinda awkward but should work.

If you just want total visits per week and other such delayed data then you can check the stats manually once a week and edit by hand :)
 
Back
Top Bottom