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.

Change DocumentRoot directive

Discussion in 'General Discussion' started by decanet, Dec 1, 2011.

  1. decanet

    decanet Registered

    Joined:
    Dec 1, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    [Resolved] Change DocumentRoot directive

    Hello,

    I have a little problem with my cPanel server. I tried to contact the cPanel support, but the link into cPanel redirect me to a spanish interface (and I can't change language).
    After a transfer from my old cPanel server to my new one, I have a problem with httpd.conf. I have a subdomain with a SSL certificate. In httpd.conf, this subdomain have the good DocumentRoot for standard access (port 80), but have the same DocumentRoot than principal domain for SSL access (port 443).
    I tried to change it manually, and restart httpd. I can access to my subdomain now with SSL.
    My problem is after cPanel rebuild Apache conf, my subdomain doesn't work with SSL, it redirects me to the principal domain.

    Thanks for your help

    Benjamin
     
    #1 decanet, Dec 1, 2011
    Last edited: Dec 1, 2011
  2. NixTree

    NixTree Well-Known Member

    Joined:
    Aug 19, 2010
    Messages:
    387
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Gods Own Country
    cPanel Access Level:
    Root Administrator
    Hello,

    Its strange that a single sub-domain has diffreent DocumentRoot for 80 and 443 access!

    Anyway, change the document root manually as you said and run the distler to persists it.

    1. Chnage Document root manually.

    2. Take a backup of current httpd.conf

    cp -p /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.11Dec1.bak

    3. Run the distiller

    /usr/local/cpanel/bin/apache_conf_distiller --update

    4. Rebuild Apche conf

    /usr/local/cpanel/bin/build_apache_conf

    5. Check and make sure the chnages has been persisted.

    Thank you,
    Nibin.
     
  3. decanet

    decanet Registered

    Joined:
    Dec 1, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Perfect it works!
    Thanks!
     
  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
    The /usr/local/apache/conf/httpd.conf file should never be directly edited for the VirtualHost section at all. This is precisely why it has this above every VirtualHost entry in caps:

    The place to properly edit an existing VirtualHost section would be /var/cpanel/userdata/username/domain.com location where username is the cPanel username and domain.com is the main domain name. If the site is an addon domain, the file would instead be called sub.domain.com where that is the subdomain name off the main domain for the addon domain.

    If you edit files in /var/cpanel/userdata, then running "/scripts/rebuildhttpdconf" command without the quotes in root SSH will rebuild the VirtualHost entry in httpd.conf file. After running the rebuild script, then restart Apache.

    If you need to add an entry to a VirtualHost that isn't a line already in the VirtualHost (unlike editing documentroot which is in that file), you'd need to use an include file instead as /usr/local/apache/conf/userdata/std/2/username/domain.com location. There is documentation on using these includes at this spot:

    Changes Contained within a VirtualHost Directive
     
Loading...

Share This Page