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.

Modification of Apache VirtualHost DocumentRoot?

Discussion in 'EasyApache' started by mickoz, Jan 26, 2007.

  1. mickoz

    mickoz Member

    Joined:
    Oct 24, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I need to migrate from a server (managed) to a cPanel server (which I will manage) about right now. And I am also quite new to cPanel (I understand it conceptually but in practice, I don't know what I can or not do under the hood without breaking it). I could test it and do more research, however after some research -- nothing that really tell me what I want to do won't break anything up. So here I go with my problem:

    For our website to work, I would have to redefine the DocumentRoot set up by cPanel for the main-domain linked to my account.

    I could do it myself, but I wonder if I will break anything doing so (e.g. cPanel might expect I do not modify anything it has generated in httpd.conf or anywhere else, so everything work well together – I imagine other cPanel options might get broken if I play with a setting cPanel manage).

    All in all, in the apache's httpd.conf, I want to change from this:

    <VirtualHost ip.address.xxx.yyy>
    ServerAlias domainname.com
    ServerAdmin webmaster@domainname.com
    DocumentRoot /home/username/public_html
    BytesLog domlogs/domainname.com-bytes_log
    ServerName www.domainname.com

    User username
    Group username
    CustomLog /usr/local/apache/domlogs/domainname.com combined
    ScriptAlias /cgi-bin/ /home/username/public_html/cgi-bin/
    </VirtualHost>

    To this:

    <VirtualHost ip.address.xxx.yyy>
    ServerAlias domainname.com
    ServerAdmin webmaster@domainname.com
    DocumentRoot /home/username/public_html/html
    BytesLog domlogs/domainname.com-bytes_log
    ServerName www.domainname.com

    User username
    Group username
    CustomLog /usr/local/apache/domlogs/domainname.com combined
    ScriptAlias /cgi-bin/ /home/username/public_html/cgi-bin/
    </VirtualHost>

    (notes: I only changed DocumentRoot's path, maybe I will want to modify ScriptAlias too of course).

    Will this break anything with cPanel? (since I change a path that he expects to follow his guideline)

    Also, can I simply override apache's VirtualHost DocumentRoot in my user's directory with some command in ".htaccess", etc. (I suppose I can, but I don't know much about htaccess possibilities, once again i can do research, but I'm hoping it is an easy answer for someone here to answer).

    Therefore if I can simply choose an override option (htaccess), my modification won't imply for me to modify the httpd.conf (which cPanel kinda manage). In my view point, if that option exists (without negative effect, e.g. major slowdown, etc.), it might be more clean to do it this way as I won't interfer with cPanel way of handling configuration, and I will have the desired effect.

    I may of course wish to remap the DocumentRoot for domains and subdomains in the future (because I hate the fact that cPanel force us to put them all in the same public_html). So my question is not only to apply this to one domain.

    If you have any other suggestion to do it a clean way without risking to break cPanel, feel free to provide!

    Thanks for your advices.
     
  2. dafut

    dafut Well-Known Member

    Joined:
    Dec 14, 2005
    Messages:
    75
    Likes Received:
    0
    Trophy Points:
    6
    Although it was with only one site on my VPS, I did something similar to handle a site that required multiple ports and hostnames.

    This is actually part of an include file that gets called in the httpd.conf file with this call:

    Include "/etc/mocha-httpd.conf"

    With it, the site's accessed on one of three ports (aside from the cPanel/WHM ports) and two of the ports are directed outside of the normal "public_html" structure. Of course I also had to set the Listen directive in httpd.conf to listen for the atypical ports (8989 and 8998), which I fixed to a specific IP address as well.

    And it works quite well. So I don't see why what you're suggesting won't work.
     
  3. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    If all you want to do is to change the DocumentRoot in httpd.conf then you can go ahead - it won't affect how cPanel functions and the cPanel scripts won't change the DocumentRoot back.
     
Loading...

Share This Page