Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there a way that I can access Apache Log files from my PHP page. Normally the apache will not allow access to outer folders. Is there any alternative way to access log files? If I get those logs I can parse them and find out bandwidth usages

Edit:

I actually want to implement a bandwidth tracking system which can track how much data, a user is downloaded form my site. or uploaded to my site. I searched in stackoverflow and found an answer which suggests parsing log file. I need to automate this so that website itself will parse the log and show the details.any idea?

share|improve this question
    
Bandwidth tracking should be done by programs specific to it, such as those that are mentioned in Capt.Nemo's system. Your apache log files won't really help determine bandwidth usage as much as they will determine which files are actually being accessed. –  Thomas W. Jan 12 '13 at 0:40

2 Answers 2

up vote 3 down vote accepted

I would agree with the other answer and recommend against serving log files via php for apache. Just as a tiny aside, if you are used to php, it can also be run as a scripting language without needing apache. So you can copy your logs and run your php script over them as well.

Since you mentioned bandwidth usage, I would suggest trying out awstats and webalizer for such usage.

share|improve this answer

I would be careful with trying to access the Apache log from anywhere other than local or SSH. Accessing the log files for Apache via PHP or a nonsecure method is not safe, as those logs can contain connection related information in them which if leaked puts users at risk.

I would, if I were you, just download the log file via SFTP or rsync or scp via SSH to your system, and then analyze the logs, rather than try and have PHP serve the log file to you.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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