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.

Documentation of properties of vhost in template?

Discussion in 'General Discussion' started by JoeMurray, May 7, 2009.

  1. JoeMurray

    JoeMurray Registered

    Joined:
    Mar 3, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I'm using cPanel for the first time, and I'd like to reconfigure how it has been configured to set up virtual hosts. The online documentation I have found is more user level rather than how to set up templates, unfortunately.

    Currently, the default action of cPanel on my new server is to put the cgi-bin directory under document root rather than the preferred more secure location of webroot:
    /home/domuser/public_html/cgi-bin
    rather than
    /home/domuser/cgi-bin

    To make this change I believe I should modify /var/cpanel/templates/apache2/vhost.default at the following:
    [% IF scriptalias == 1 -%]
    ScriptAlias /cgi-bin/ [% vhost.documentroot %]/cgi-bin/
    [% END -%]

    to something like:
    [% IF scriptalias == 1 -%]
    ScriptAlias /cgi-bin/ [% vhost.webroot %]/cgi-bin/
    [% END -%]

    or maybe:
    [% IF scriptalias == 1 -%]
    ScriptAlias /cgi-bin/ [% vhost.homedir %]/cgi-bin/
    [% END -%]

    Unfortunately, I can't find documentation on what the properties of vhost are, or what ones that I can see already in the file like homedir contain.

    Advice on a) how to handle this issue, and b) where to find documentation, would be appreciated. I have another issue where I want to serve multiple domains from the same directory, and I will need to rewrite some templates for that, I believe.
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    The related EasyApache documentation can be found at:

    http://www.cpanel.net/documentation/easyapache/customdirectives.html

    You would create /var/cpanel/templates/apache2/vhost.local (perhaps by copying the contents from /var/cpanel/templates/apache2/vhost.default) and edit vhost.local instead. EasyApache will then use the contents of vhost.local instead. I advise against editing vhost.default directly.

    I would use vhost.homedir. I am not aware if vhost.webroot is valid.

    To have multiple domains serve the same content as the primary domain of a cPanel account, just use the Parked Domains functionality in cPanel interface for that primary domain.
     
  3. JoeMurray

    JoeMurray Registered

    Joined:
    Mar 3, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Thanks!

    Thanks cPanelDavidG.

    I'd seen the documentation you link to but didn't find the info I needed in it.

    Thanks for the suggestion re: parked domains, which should work when I want the same content provided to different domains.

    The use case I'm more interested in is using a single codebase for a CMS - Drupal - to support multiple sites. A few config files and themes and uploaded data get stored in site specific subdirectories, with the content in a db for each site.

    The directory structure I want to create for each of these domains is
    /home/commondir/files/site1 - domain specific files
    /home/commondir/files/site2 - domain specific files
    /home/commondir/files/siten - domain specific files
    /home/commondir/public_html -- lots of stuff
    /home/commondir/public_html/sites/site1 - symlink to /home/commondir/files/site1
    /home/commondir/public_html/sites/site2 - symlink to /home/commondir/files/site2
    /home/commondir/public_html/sites/siten - symlink to /home/commondir/files/siten

    I want useraccountX to be set automatically to be able to access /home/commondir/files/siteX but not the /home/commond/public_html and for apache to be able to read all of those files as well. In many cases, I'll also be setting up ssl versions of sites so they can do some online payments as well, so I'll do the same config changes to my new ssl_vhost.local file.

    Where would I go to change which directories are created when a new account is set up, and to have the symlinks setup appropriately? I think I can handle the changes to the vhost.local and ssl_vhost.local files at this point.

    Cheers,
    Joe
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    If you were to use addon domains rather than parked domains, you can specify the path that the addon domain pulls files from which can even be outside public_html (e.g. /home/username/path/to/files/for/site1).

    The main issue I see is with using addon domains is SSL certificates. If you are using a regular SSL cert that is good for 1 domain, you'll need a dedicated IP address for that domain. At this time, cPanel/WHM only supports a maximum of 1 IP address being dedicated to a cPanel account.

    If you want to attempt the route of doing each domain as its own cPanel account, you could create /scripts/postwwwacct to handle the creation of any symlinks that are needed upon the provisioning of a new cPanel account. Documentation for that is available at:

    http://twiki.cpanel.net/twiki/bin/view/AllDocumentation/ScriptHooks#scripts_postwwwacct
     
Loading...

Share This Page