LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Apache Server and Hit Counter (https://www.linuxquestions.org/questions/linux-software-2/apache-server-and-hit-counter-340062/)

k1ll3r_x 07-04-2005 09:45 PM

Apache Server and Hit Counter
 
Well i was using Apache on linux for quite a while, and it never occured to me, to use a counter, im currently running it on a windows machine, and im wondering, if anyone knows of apache using hit counters, and if anyone knows of one, or anything similar to this, just to keep track of how many people visit the website, id like to know please, i will really appreciate.
- Jerry V.

michaelsanford 07-05-2005 12:38 AM

Most hit counters are pretty plain-vanilla, if you find one that uses PHP and MySQL it doesn't matter what platform they're running on (as long as you have PHP and MySQL of course).

You can even write a quick one in PHP that uses a flat-file and doesn't even need MySQL...

k1ll3r_x 07-05-2005 12:40 AM

how could i do that though? i have some source code thingy, i dont know how to get it going
Code:

#!/usr/bin/perl

# Open the counter file
open(HITS,"counter.txt");
$count=<HITS>;
close(HITS);
# Check if the counter is a valid number
if($count ~! m/[0-9]*/){$count=0}
# Increment the count
$count++;
# Record the count
open(HITS,"+>counter.txt");
print HITS $count;
close(HITS);
# Report the count
print "content-type:text/html\n\nYou are visitor $count";
exit;


michaelsanford 07-05-2005 12:50 AM

That's a PERL (CGI) script, I'm afraid I'm a PHP kid and don't know much about PERL.

AFAIK you'd have to put a reference to that script in your page somewhere and put the script itself in the CGI-BIN directory of Apache and make it chmod +x.

Don't take my word on it though, get a PERL guy to tell you.

RanDrake10 07-05-2005 06:58 AM

Try this link
http://www.muquit.com/muquit/software/Count/Count.html
This counter will work in Linux & Windows.


All times are GMT -5. The time now is 12:26 AM.