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.

Custom Apache Include for Single Virtual Host

Discussion in 'EasyApache' started by mikelegg, Jul 30, 2012.

  1. mikelegg

    mikelegg Well-Known Member

    Joined:
    Mar 29, 2005
    Messages:
    330
    Likes Received:
    0
    Trophy Points:
    16
    I"m a bit confused about the proper location for custom apache includes for single virtual hosts.

    The first part of Changes Contained within a VirtualHost Directive says

    But under the heading "Custom templates that will apply to a single virtual host when rebuilding an existing Apache configuration" it says ...

    Can someone please help me understand this?
     
  2. Brian

    Brian Well-Known Member

    Joined:
    Dec 1, 2010
    Messages:
    117
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Texas
    cPanel Access Level:
    Root Administrator
    Those are two entirely unique concepts that you've listed.

    1. Includes
    2. Templates

    Which one you want to use depends on what type of change(s) you want to enact.

    If you only want to add simple static directives to a user's <VirtualHost>, then you want to use the "Include" method on that page. That involves simply slapping down a file at:

    Code:
    Apache 1 with SSL — /usr/local/apache/conf/userdata/ssl/1/$user/$domain/$includename.conf
    Apache 2 with SSL — /usr/local/apache/conf/userdata/ssl/2/$user/$domain/$includename.conf
    Apache 1 without SSL — /usr/local/apache/conf/userdata/std/1/$user/$domain/$includename.conf
    Apache 2 without SSL — /usr/local/apache/conf/userdata/std/2/$user/$domain/$includename.conf
    
    and then following the remainder steps for verifying/ensuring the includes are recognized and included to httpd.conf

    On the other hand, the "Custom Templates" option is for:
    • If you want to modify the directives that cPanel & WHM already puts in place for a <VirtualHost>
    • If the directives that you're adding would benefit from the cPanel template system variables to auto-populate certain information about the user account.

    However, unless you absolutely need the benefits of the custom template method, I would otherwise strongly recommend the include method. Why? With the template method you're taking a static snapshot of the vhost template cPanel has deployed and then modifying it. When we make changes to that template design in the future, any places you've copy/paste/modified the template would then be based off of the old/stale template and wouldn't have any updates we made. This could cause those particular <VirtualHost>s to be unable to use new features or, potentially, break entirely. You'd have to then re-copy a fresh version of the updated template and re-implement the customizations again. "Includes" are much less invasive and much less likely to cause such problems down the road.
     
  3. mikelegg

    mikelegg Well-Known Member

    Joined:
    Mar 29, 2005
    Messages:
    330
    Likes Received:
    0
    Trophy Points:
    16
    Thanks Brian - makes sense now.
     
Loading...

Share This Page