Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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 Ward Jan 12 '13 at 0:40
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


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.