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 VirtualHost configurations

Discussion in 'General Discussion' started by jez9999, Mar 6, 2009.

  1. jez9999

    jez9999 Well-Known Member

    Joined:
    Jun 10, 2005
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    6
    OK, the idea with the new Apache2/EasyApache system is that we try not to edit the httpd.conf at all, and use include files for customization instead, right? Fair enough. However I'm a bit confused about all the VirtualHost section comments, like this:

    Code:
        # To customize this VirtualHost use an include file at the following location
        # Include "/usr/local/apache/conf/userdata/std/2/gamept/domain.com/*.conf"
    Let's say I made a file /usr/local/apache/conf/userdata/std/2/gamept/domain.com/config.conf, and overwrite a setting in that VirtualHost entry by putting something like 'ServerAdmin joe@bloggs.com' in it. Fine... but then what? That file won't get included, will it? The Include statement in the httpd.conf is commented out. How do I get it to actually apply that VirtualHost include file?
     
  2. jez9999

    jez9999 Well-Known Member

    Joined:
    Jun 10, 2005
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    6
    To answer my own question, after a bit of experimentation, this is what you do.

    1. Create the directory specified in the VirtualHost block's comment; in this case, 'mkdir -p /usr/local/apache/conf/userdata/std/2/gamept/domain.com/'.
    2. Go to that directory.
    3. Create some file(s) ending .conf; eg. config.conf.
    4. Edit that file/files, and add directive(s) you want to further customize that VirtualHost block with.
    5. Finally, run '/scripts/ensure_vhost_includes --all-users' to regenerate the httpd.conf file. If it detects that there are .conf files in the appropriate directory for that VirtualHost block, it will uncomment that Include line and include the .conf file(s) in that directory.

    Now -- feature request to the cPanel developers. Could you please make this clearer in the comments you put in the VirtualHost blocks? You need to create the foo.conf file in that directory first, then run '/scripts/ensure_vhost_includes --all-users'? It's not that obvious. Thanks.
     
  3. CrazyCharlie

    CrazyCharlie Registered

    Joined:
    Sep 1, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Change or overwrite a VirtualHost directive?

    Is there a way to overwrite a directive in a VirtualHost with the include file such as the ServerAlias? I have a listing in the Apache conf that has some URLs that shouldn't be in the ServerAlias but not sure how to remove them via an external include file.

    Here's an example:

    In httpd.conf -

    <VirtualHost XX.XX.XX.XX:80>
    ServerName SITENAME.com
    ServerAlias www.UNWANTEDURL.com www.SITENAME.com SUBDOMAIN.SITENAME.com UNWANTEDURL.com www.SUBDOMAIN.SITENAME.com
    DocumentRoot /home/SITENAME/public_html
    ServerAdmin webmaster@SITENAME.com
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/SITENAME.com combined
    CustomLog /usr/local/apache/domlogs/SITENAME.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User SITENAME# Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
    suPHP_UserGroup SITENAME SITENAME
    </IfModule>
    <IfModule !mod_disable_suexec.c>
    SuexecUserGroup SITENAME SITENAME
    </IfModule>
    ScriptAlias /cgi-bin/ /home/SITENAME/public_html/cgi-bin/


    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/std/2/SITENAME/SITENAME.com/*.conf"

    </VirtualHost>

    I've created an "update.conf" file to try and remove the unwanted URL listings but it doesn't work. These unwanted URLs are preventing a proper redirect so if I test by commenting out that ServerAlias line and putting in a new line without the unwanted URLs my problem is solved. However, I'd like to do it so the directive doesn't keep getting overwritten with Cpanel or other Apache updates.

    Any help would be greatly appreciated.
     
Loading...

Share This Page