Category Archives: PHP

I have written a PHP class that can be used to parse the Apache access.log file. The data can then be displayed in a custom manner that is easier to read or that only includes the data you really care about. You could also insert the data into a database or recordset so you could then sort or filter / search it.

A couple years ago I setup a linux box running Apache, PHP and MySQL. A couple weeks later MySQL and Apache crashed and would not start. After doing some troubleshooting and a little google-fu I discovered that the file /var/log/apache2/access.log file had grown so large it took up all available space root drive. It turns out that when you have a running web server, it tends to attract a lot of attention from shady individuals who will continually scan your server for vulnerabilities.

First, I just blocked all traffic through the firewall except only from a few trusted networks. This was not ideal for me as the purpose of setting up the Apache server was to be able to access it when away from home. This got me thinking of how to find out who was accessing my web server the most so I could block them. This lead me back to the access.log file. Trying to read this file manually and make sense of it was not going to be very likely.

I tried searching for PHP solutions to parsing and displaying the access.log file in a more readable way. I found a few paid solutions but I was looking for something free. I found a couple sources but none of the code seemed to work properly so I set out to write it myself. And now I am sharing it with the internet.