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.

Main site folder in public_html

Discussion in 'General Discussion' started by User 2011, Jun 9, 2011.

  1. User 2011

    User 2011 Member

    Joined:
    May 9, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Hi guys...just a quick question. My main ( first ) site in cPanel is in folder public_html. I have few other folders alongside the main site that hold add-on domains. Question is - is it possible to create a folder in public_html and put all your files from main site into it ? I've done it but server responded with error so I assume you cannot do it like with add-on domain folders. I simply would like to make it more 'tidy' in public_html..Thanks for any comments.
     
  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
    Hello,

    If you have direct root SSH access to the machine, you can modify the documentroot line in /var/cpanel/userdata/username/domain.com location so that public_html is not the document root. The contents might look similar to the following initially for the file:

    Code:
    --- 
    customlog: 
      - 
        format: combined
        target: /usr/local/apache/domlogs/domain.com
      - 
        format: "\"%{%s}t %I .\\n%{%s}t %O .\""
        target: /usr/local/apache/domlogs/domain.com-bytes_log
    documentroot: /home/username/public_html
    group: username
    hascgi: 1
    homedir: /home/username
    ip: IP#.IP#.IP#.IP#
    options: ExecCGI Includes
    owner: root
    phpopenbasedirprotect: 1
    port: 80
    scriptalias: 
      - 
        path: /home/username/public_html/cgi-bin
        url: /cgi-bin/
    serveradmin: webmaster@domain.com
    serveralias: www.domain.com
    servername: domain.com
    usecanonicalname: 'Off'
    user: username
    You would want to modify any paths in that file that have /home/username/public_html to the new location you want the contents to be, then save the file. After changing the contents, you would then issue the following to save the Apache configuration, rebuild Apache's configuration and restart Apache:

    Code:
    cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak110609
    /scripts/rebuildhttpdconf
    /scripts/restartsrv_httpd
    Thanks!
     
  3. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,446
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Do you mean you'd like to move your main website from the root of the domain to a directory?

    Instead of your website being here: yourdomain.com
    You'd like to move it to here: yourdomain.com/site/

    The short answer is yes, sure.

    The long answer might depend on the sort of website you have running at yourdomain.com. If it was just a couple of html files (EG index.html, contactus.html, products.html) moving those wouldn't give you an error, unless you tried to access one of them at the old location.

    If you've got a wordpress blog for example, there are a few extra steps you'd need to take.
     
  4. User 2011

    User 2011 Member

    Joined:
    May 9, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Thanks guys. For the record, I meant movig the files into the folder to make it like an add-on folder in public_html. but without changing the address - so you can still access by www.yourdomain.com. but the main site files are in a folder named yourdomain.com for example. Your answers explain much - cheers !
     
  5. 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 scenario you explain can really only be done with either a rewrite to mask the url, which isn't ideal, or using the steps I indicated to change the document root. If you have root SSH access to the machine, you should simply change the document root using the steps I noted. This will have the main domain housed in that different location.
     
  6. southbay

    southbay Member

    Joined:
    Aug 17, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    I am trying to do this for an end user but when I attempt to save/rebuild/restart, I am getting the message:
    cp: target '/scripts/restartsrv_httpd' is not a directory

    Can you shed any light on this?
     
  7. 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
    It sounds like you've appended all 3 lines together rather than running 3 separate commands. Please post the full output of what you put into command line.
     
  8. southbay

    southbay Member

    Joined:
    Aug 17, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    You are correct..I ran the 3 commands separately, sucessfully. thank you. sorry for my ignorance.

    Thank you, again, for your speedy response to this problem.
     
Loading...

Share This Page