Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Oct 2006
    Posts
    7

    Default Modification of Apache VirtualHost DocumentRoot?

    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. #2
    Member dafut's Avatar
    Join Date
    Dec 2005
    Posts
    75

    Default

    Although it was with only one site on my VPS, I did something similar to handle a site that required multiple ports and hostnames.

    # MOCHA's PACO Configuration
    <VirtualHost paco.domain.com:8989>
    ServerAdmin support@domain.com
    DocumentRoot /home/bilybobb/mocha/paco/htdocs
    ServerName paco.domain.com
    ScriptAlias /cgi-bin/mocha/ /home/bilybobb/mocha/paco/cgi-bin/
    Redirect permanent index.html http://paco.domain.com:8989/cgi-bin/mocha/paco-main.pl
    ErrorLog /var/log/mocha-log/paco-error_log
    TransferLog /var/log/mocha-log/paco-access_log
    SetEnv PERL5LIB /home/bilybobb/mocha/intranet/modules/
    SetEnv MOCHA_CONF /etc/mocha.conf


    User bilybobb
    Group bilybobb
    CustomLog /usr/local/apache/domlogs/mocha.domain.com combined


    </VirtualHost>

    # MOCHA's INTRANET Configuration
    <VirtualHost mocha.domain.com:8998>
    ServerAdmin support@domain.com
    DocumentRoot /home/bilybobb/mocha/intranet/htdocs
    ServerName mocha.domain.com
    ScriptAlias /cgi-bin/mocha/ /home/bilybobb/mocha/intranet/cgi-bin/
    Redirect permanent index.html http://mocha.domain.com:8998/cgi-bin/mocha/mainpage.pl
    ErrorLog /var/log/mocha-log/mocha-error_log
    TransferLog /var/log/mocha-log/mocha-access_log
    SetEnv PERL5LIB /home/bilybobb/mocha/intranet/modules
    SetEnv MOCHA_CONF /etc/mocha.conf

    User bilybobb
    Group bilybobb
    CustomLog /usr/local/apache/domlogs/mocha.domain.com combined
    </VirtualHost>

    <VirtualHost mocha.domain.com:80>
    ServerAlias mocha.domain.com library.domain.com
    ServerAdmin webmaster@domain.com
    DocumentRoot /home/bilybobb/public_html
    BytesLog /usr/local/apache/domlogs/mocha.domain.com-bytes_log
    User bilybobb
    Group bilybobb
    ServerName mocha.domain.com

    <IfModule mod_userdir.c>
    Userdir disabled
    Userdir enabled bilybobb
    </IfModule>

    <IfModule mod_php4.c>
    php_admin_value open_basedir "/home/bilybobb:/usr/lib/php:/usr/local/lib/php:/tmp"
    </IfModule>
    <IfModule mod_php5.c>
    php_admin_value open_basedir "/home/bilybobb:/usr/lib/php:/usr/local/lib/php:/tmp"
    </IfModule>

    User bilybobb
    Group bilybobb
    CustomLog /usr/local/apache/domlogs/mocha.domain.com combined
    ScriptAlias /cgi-bin/ /home/bilybobb/public_html/cgi-bin/
    </VirtualHost>
    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. #3
    Super Moderator This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,495

    Default

    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.
    Jonathan Michaelson

    Need your cPanel servers secured and tuned?
    cPanel Server Configuration, Security, Recovery and Antivirus/AntiSpam Services
    Developers of the most effective (and free) Firewall & Security Solution for cPanel Servers - csf
    http://www.configserver.com

Similar Threads & Tags
Similar threads

  1. Apache does not start: Virtualhost *:8181 ...
    By noox in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 12-14-2009, 07:22 AM
  2. apache not properly setting default virtualhost?
    By SMG in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 12-11-2007, 06:33 AM
  3. Problem!! [warn] VirtualHost x.x.x.x:80 overlaps with VirtualHost x.x.x.x:80
    By psnsupport in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 10-17-2005, 04:34 AM
  4. apache custom virtualhost support?
    By jonahbenton in forum New User Questions
    Replies: 3
    Last Post: 06-19-2004, 09:48 AM
  5. Apache Modification
    By kmoonlight in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 04-21-2003, 10:26 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube