Wednesday, June 13, 2012

PHP error logs with Apache Vhost configuration

Error logs are my friend.  We have become very close over the past 12 months.  As an administrator, I am DEPENDENT on them to monitor performance and behavior of moodle instances. If I were running only a single version of moodle or more generically, a single website on my server, my Apache server, I would have only one place where the location of the php error logs would exist.  The php Error handling and logging section of the php.ini file would define the type of error reporting and the location.

For single website setup, look for php directives

error_log = filename - location of error log
error_reporting = something here -  how much robustness do you want?

On our moodle servers, we are hosting multiple sites, which means using the Apache directive Vhost to specify the name and location of the error log.  I am sending the access logs to a separate folder that the error logs.

Each Vhost definition in the httpd-vhosts.conf file contains these two lines:

    CustomLog "C:\logs\access\entityName_access.log" common
    ErrorLog "C:\logs\EntityName_error.log"



These directives are of particular interest to me, since they hold the keys to solving mysterious web server reporting and behavior!

A couple observations about the main Apache configuration file httpd-conf.

It takes a modular approach to its many directives and settings.  I think in the earlier days of Apache, the settings all lived in the this main file.  As new features and directives evolved, their inclusion became more modular.

Even with the Vhost directive active, and many web sites living on a server, there is still just one version of Apache supporting them all, most of the directives are server wide, global to all of the websites defined in the httpd-vhosts.conf file.  Global Apache settings include
Port
ServerRoot
ServerAdmin email
ServerName
DocumentRoot
ErrorLog

This is copied from the httpd.conf file

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a
# container, that host's errors will be logged there and not here.
#
# ErrorLog "logs/error.log"


I noticed the ErrorLog directive was enabled, when it did not have to be, since I am using '' and do have specific error logs specified. I commented out the ErrorLog setting in the main file, which should have an explicit drive letter in front of it.



1 comment: