Disable error_log per virtual host

bsasninja

Well-Known Member
Sep 2, 2004
527
0
166
Is there a way at httpd.conf to disable error_log per vhost?? I dont want to comment the error_log parameter cause that will stop logging all errors on the server. I would like to apply it to a specific domain.

Thank you!
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello,

There would not be a way to maintain the global error_log location and yet revoke it for one domain. Instead you would have to add an ErrorLog line per VirtualHost entry using includes in place of the global ErrorLog line, which would require customizing the /var/cpanel/templates/apache2/main.default file and adding includes in /usr/local/apache/conf/userdata/ location.

In the main.default file, you'd have to copy it first:

Code:
 cp /var/cpanel/templates/apache2/main.default /var/cpanel/templates/apache2/main.local
Then you'd edit the main.local file to remove the ErrorLog lines.

After removing the global ErrorLog location, you'd then need to add include files at /usr/local/apache/conf/userdata/std/2/$user/$domain/$includename.conf for each domain with the ErrorLog line and path. Of note, in the path mentioned, std is the standard port 80 VirtualHost entry, 2 is Apache 2, $user is the cPanel username, $domain is the domain name, and $includename.conf is the name you use for the include file.

The include file name can be anything so long as it ends in .conf so something like errorlog.conf would work for the file's name. In this setup, if you don't want one domain to have any error_log, simply don't have an include for the ErrorLog location.

You can find details on using the includes for each VirtualHost at the following location:

Changes Contained within a VirtualHost Directive

After you have everything setup the way you would like, you would run the following commands to backup Apache's configuration (always perform a backup of Apache prior to making any changes), check the includes are properly working, distill the includes for all users, rebuild Apache and then re-start Apache:

Code:
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak110224
/scripts/verify_vhost_includes
/scripts/ensure_vhost_includes --all-users
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
Thanks.