The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Disable error_log per virtual host

Discussion in 'General Discussion' started by bsasninja, Feb 24, 2011.

  1. bsasninja

    bsasninja Well-Known Member

    Sep 2, 2004
    Likes Received:
    Trophy Points:
    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!
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Oct 2, 2010
    Likes Received:
    Trophy Points:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator

    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:

     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:

    cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak110224
    /scripts/ensure_vhost_includes --all-users
    /etc/init.d/httpd restart

Share This Page