Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 





Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read

Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
Thread Tools
Old 11-08-2005, 05:15 AM   #1 (permalink)
Registered User
 
Join Date: Nov 2005
Posts: 4
OS: XP


Apache 2.0 logfile setup

How do I setup the Apache 2.0 so that, if possible at all, I get information in the logfile that shows where visitors came from?
renewest is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 11-08-2005, 01:41 PM   #2 (permalink)
tgo
Registered User
 
Join Date: Jul 2005
Posts: 185
OS: slackware 10.1


Send a message via AIM to tgo
I dont think apache holds referers in logs except for on some errors. But here is a php script I wrote that count unique hits that you can use.

Code:
<?php
// get name of current page
$script = $_SERVER['PHP_SELF'];

// break the array in directories and the script name
$all = explode('/',$script);

//get name of page
$spot = count($all) -1;
$script = $all[$spot];
$ip = $_SERVER['REMOTE_ADDR'];

// query to check for whether the page is in the table or not
$link = "SELECT * FROM hits WHERE script='$script'";
$res = mysql_query($link) or die(mysql_error());
$total = mysql_num_rows($res);
$row = mysql_fetch_assoc($res);

// if its not then add it with one hit
if ($total == 0)
{
	$add = "INSERT INTO hits VALUES('$script','1','$ip')";
	$addit = mysql_query($add) or die(mysql_error());
}
else
{
        // if it is and its not from an ip thats already hit it then add it	
	$ips = $row['ips'];
	if (!strstr($ips,$ip))
	{
		$newtotal = $row['total'] + 1;
		$ips .= $ip;
		$update = mysql_query("UPDATE hits SET total='$newtotal',ips='$ips' WHERE script='$script'") or die(mysql_error());
	}
}
?>
And the code to make the table:

Code:
<?php
 $stats = "CREATE TABLE `hits` (
    `script` TEXT NOT NULL,
    `total` INT ( 11 ),
    `ips` TEXT NOT NULL );";
    $table = mysql_query($stats) or die(mysql_error());
?>
To use it just create the table and name the file stats.php. Then whatever pages you want tracked add

<?php include("stats.php"); ?>
__________________
My new homepage:

Last edited by tgo : 11-08-2005 at 02:11 PM.
tgo is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 11-09-2005, 05:07 PM   #3 (permalink)
Be Free
 
LoneWolf071's Avatar
 
Join Date: Nov 2004
Location: Texas
Posts: 833
OS: Windows XP, Linux


Send a message via AIM to LoneWolf071
or you could just look in the /var/log/apache or apache2 dir where all the log files are kept.
__________________
Suicide Command in Linux : rm -rf / ;)
AIM:TheLoneWolf071@aim.com--If You Need Help, Don't Hesitate...
LoneWolf071 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 11-09-2005, 05:46 PM   #4 (permalink)
tgo
Registered User
 
Join Date: Jul 2005
Posts: 185
OS: slackware 10.1


Send a message via AIM to tgo
Quote:
Originally Posted by LoneWolf071
or you could just look in the /var/log/apache or apache2 dir where all the log files are kept.
Only error_log holds the referer so thats not very useful.
__________________
My new homepage:
tgo is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 11-09-2005, 06:09 PM   #5 (permalink)
Be Free
 
LoneWolf071's Avatar
 
Join Date: Nov 2004
Location: Texas
Posts: 833
OS: Windows XP, Linux


Send a message via AIM to LoneWolf071
no, apache also writes access.log which tells where they came from...

192.168.1.1 - - [08/Nov/2005:20:02:49 -0600] "GET /testphp.php HTTP/1.1" 200 171 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1...

that's quite helpful in locating where there from and what their doing...
__________________
Suicide Command in Linux : rm -rf / ;)
AIM:TheLoneWolf071@aim.com--If You Need Help, Don't Hesitate...
LoneWolf071 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 11-09-2005, 09:29 PM   #6 (permalink)
Tech, Networking Forums
 
Squashman's Avatar
 
Join Date: Apr 2005
Location: 1265 Lombardi Ave.
Posts: 1,005
OS: All of the above


Why not just use Awstats.
http://awstats.sourceforge.net/
Squashman is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 11-09-2005, 11:38 PM   #7 (permalink)
Registered User
 
Join Date: Nov 2005
Posts: 4
OS: XP


Hi,
I am using Awstats and it works great except that some info is missing i.e. :
browser type
OS
referer
search criteria


My question is how can I configure APache 2.0 in such a way that it does log these data.

Rene
renewest is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 11-10-2005, 06:39 AM   #8 (permalink)
Be Free
 
LoneWolf071's Avatar
 
Join Date: Nov 2004
Location: Texas
Posts: 833
OS: Windows XP, Linux


Send a message via AIM to LoneWolf071
again, the apache access log file tells you all that info...

192.168.1.1 - - [08/Nov/2005:20:02:49 -0600] "GET /testphp.php HTTP/1.1" 200 171 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1... -- That's Telling You What OS, What Browser, It Tells You what they access and what criteria they enter. it's very good at what it does... /var/log/apache/access.log or /var/log/apache2/access.log
__________________
Suicide Command in Linux : rm -rf / ;)
AIM:TheLoneWolf071@aim.com--If You Need Help, Don't Hesitate...
LoneWolf071 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 11-10-2005, 11:44 AM   #9 (permalink)
Tech, Networking Forums
 
Squashman's Avatar
 
Join Date: Apr 2005
Location: 1265 Lombardi Ave.
Posts: 1,005
OS: All of the above


Quote:
Originally Posted by renewest
Hi,
I am using Awstats and it works great except that some info is missing i.e. :
browser type
OS
referer
search criteria
I just went to the Awstats Demo and it shows all that stuff. What am I not understanding.
Squashman is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -7. The time now is 04:01 AM.



Copyright 2001 - 2008, Tech Support Forum

Search Engine Friendly URLs by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82