Domain Level Error Logging in Apache/PHP in Linux

The error logging functionality of apache is very important especially when you are testing things out with your php application. But on some cases we experience problems which hinder us from locating the error_log file where all errors, problems or warnings reside whenever we attempt to debug our application.

Problems we usually encounter are: Where’d my error_log file go? How can I enable it? It’s enabled but I don’t see any error_log inside my ./public_html/ folder.

On most cases we experience these problems while we’re setting up a Linux server with apache and php pre-installed. I have never experienced this issue before until I migrated into a cloud instance.

The server has whm/cpanel installed but I cannot find an error_log file inside the public_html folder. Took me hours to make it work only when I found out that the solution was pretty simple. I’m still finding a way on how to make the error_log file automatically created when an error occurs.

Anyway, here’s how I solved it.

Firstly, make sure that error reporting is enabled and configured in your web-server. You can verify if its working by viewing the phpinfo().


Create a file named error_log inside your public_html / www folder (this is the same directory where you put your index.php file or landing pages).

create a file named error_log

Add ‘read’ permission for ‘owner’ to file error_log so you can view it later.

add permission

Add ‘write’ permission for ‘others’ to file error_log so apache / httpd can write to it.

add permission

This is what your error_log should look like after you execute an ‘ls -lh’ command.

error_log attributes

Now, that the error_log has been created, expect it to be filled with logs once an error occurs in your application. You may view error_log contents by using either the ‘more error_log’ or ‘tail error_log’ commands.

more error_log

At the moment, I still have no clue why the error_log is not being auto-generated when an error occurs and when the error_log file is not present inside public_html. Based from the previous servers I handled, the error_logs have been automatically created when necessary.