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.

Editing httpd template

Discussion in 'General Discussion' started by jj@24khost, Nov 1, 2011.

  1. jj@24khost

    jj@24khost Well-Known Member

    Joined:
    May 27, 2009
    Messages:
    51
    Likes Received:
    0
    Trophy Points:
    6
    So I want to make the virtual hosts that are for the ip's to direct to different directories.

    I have figured that out but anytime the httpd.conf gets rebuilt i loose it.

    I found the templates and understand the language generally my only problem is there is not a list that i can find that tells me what i can and can't do and how i specify that instaed of [% ServerName %] i want the ip only for the server name and to add the alias with the same information.

    Also is there a way to add this information based on who the dedicated ip is assigned to.
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Can you please provide the existing example of how it is normally and what you revise it to look like so I know specifically what you are doing?
     
  3. jj@24khost

    jj@24khost Well-Known Member

    Joined:
    May 27, 2009
    Messages:
    51
    Likes Received:
    0
    Trophy Points:
    6
    Origional in httpd.conf
    Code:
    # DO NOT EDIT. AUTOMATICALLY GENERATED.  IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.
    NameVirtualHost 192.168.1.149:80
    NameVirtualHost 192.168.1.150:80
    NameVirtualHost 192.168.1.151:80
    NameVirtualHost *
    # DO NOT EDIT. AUTOMATICALLY GENERATED.  IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.
    
    <VirtualHost 192.168.1.149:80>
        ServerName 192.168.1.149
        DocumentRoot /usr/local/apache/htdocs
        ServerAdmin [email]admin@email.com[/email]
        <IfModule mod_suphp.c>
            suPHP_UserGroup nobody nobody
        </IfModule>
        UserDir disable
    </VirtualHost>
    
    # DO NOT EDIT. AUTOMATICALLY GENERATED.  IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.
    
    <VirtualHost 192.168.1.150:80>
        ServerName server.domain.com
        DocumentRoot /usr/local/apache/htdocs
        ServerAdmin [email]admin@email[/email]
        <IfModule mod_suphp.c>
            suPHP_UserGroup nobody nobody
        </IfModule>
        UserDir disable
    </VirtualHost>

    what i want is this
    Code:
    <VirtualHost 192.168.1.150:80>
        ServerName 192.168.1.150    
        DocumentRoot /home/reseller/public_html/default_server_page    
        ServerAdmin [email]admin@email[/email]
        ServerAlias 192.168.1.150
        UserDir disabled
        UserDir enabled reseller 
        <IfModule mod_suphp.c>
            suPHP_UserGroup reseller reseller
        </IfModule>
    </VirtualHost>

    I know i would edit this in the main.default template

    Code:
    [%- FOREACH vh IN sharedips -%]
    # DO NOT EDIT. AUTOMATICALLY GENERATED.  IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.
    
    <VirtualHost [% vh %]>
        ServerName [% servername %]
        DocumentRoot [% serverroot %]/htdocs
        ServerAdmin [% serveradmin %]
        [%- IF supported.mod_suphp %]
        <IfModule mod_suphp.c>
            suPHP_UserGroup nobody nobody
        </IfModule>
        [%- END %]
        [%- IF supported.mod_userdir && userdirprotect_enabled && defaultvhost.userdirprotect != '-1' %]
        UserDir disable
        [%- IF defaultvhost.userdirprotect != '' %]
        UserDir enabled [% defaultvhost.userdirprotect %]
        [%- END -%]
        [%- END %]
    </VirtualHost>
    
    [% END -%]
    
    
    but what would i change it to?
     
    #3 jj@24khost, Nov 1, 2011
    Last edited: Nov 1, 2011
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You cannot change the main.default template and have it stick either. You'd copy /var/cpanel/templates/apache2/main.default to /var/cpanel/templates/apache2/main.local then edit the file.

    You would want to change to this:

    Code:
    <VirtualHost [% vh %]>
    ServerName 192.168.1.150    
        DocumentRoot /home/reseller/public_html/default_server_page    
        ServerAdmin [% serveradmin %]
        <IfModule mod_suphp.c>
            suPHP_UserGroup reseller reseller
        </IfModule>
       UserDir disabled
        UserDir enabled reseller
    </VirtualHost>
    If that doesn't work, then you may need to add one of the [%- END %] before the closing VirtualHost entry. You can then test if it rebuilds properly using:

    Code:
    /scripts/rebuildhttpdconf
    /etc/init.d/httpd restart
    I removed ServerAlias as there's no point for that to exist if you are putting the same as the ServerName for it.
     
  5. jj@24khost

    jj@24khost Well-Known Member

    Joined:
    May 27, 2009
    Messages:
    51
    Likes Received:
    0
    Trophy Points:
    6
    [%- FOREACH vh IN sharedips -%]

    is there a way to get instead of sharedips, get the ip's that are assigned to resellers?
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Not that I am aware. If you want to create individual VirtualHost entries for each reseller, you'll have to use includes in /usr/local/apache/conf/userdata location instead. That folder doesn't exist by default and you could review the documentation at the following location:

    Changes Contained within a VirtualHost Directive
     
Loading...

Share This Page