Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Member
    Join Date
    May 2011
    Posts
    6

    Default Main site folder in public_html

    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. #2
    cPanel Staff cPanelTristan's Avatar
    Join Date
    Oct 2010
    Location
    somewhere over the rainbow
    Posts
    6,305
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: Main site folder in public_html

    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!
    cPResources: Support Options | More Support Options | Forums Search | cPanel.net Site Search | Mailing Lists(Alt) | Docs
    -- Tristan, Forums Technical Analyst, cPanel Tech Support

    Submit a ticket | Check an existing ticket

  3. #3
    cPanel Product Evangelist Infopro's Avatar
    Join Date
    May 2003
    Location
    Pennsylvania
    Posts
    7,894
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: Main site folder in public_html

    Quote Originally Posted by User 2011 View Post
    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.
    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.
    Fav cPlinks this week: Blog - cPanel & WHM 11.32 we love it! | cPanel University study for it! | Attracta is coming! we want this!

  4. #4
    Member
    Join Date
    May 2011
    Posts
    6

    Default Re: Main site folder in public_html

    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. #5
    cPanel Staff cPanelTristan's Avatar
    Join Date
    Oct 2010
    Location
    somewhere over the rainbow
    Posts
    6,305
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: Main site folder in public_html

    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.
    cPResources: Support Options | More Support Options | Forums Search | cPanel.net Site Search | Mailing Lists(Alt) | Docs
    -- Tristan, Forums Technical Analyst, cPanel Tech Support

    Submit a ticket | Check an existing ticket

  6. #6
    Registered User
    Join Date
    Aug 2011
    Posts
    2

    Default Re: Main site folder in public_html

    Quote Originally Posted by cPanelTristan View Post
    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!
    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. #7
    cPanel Staff cPanelTristan's Avatar
    Join Date
    Oct 2010
    Location
    somewhere over the rainbow
    Posts
    6,305
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: Main site folder in public_html

    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.
    cPResources: Support Options | More Support Options | Forums Search | cPanel.net Site Search | Mailing Lists(Alt) | Docs
    -- Tristan, Forums Technical Analyst, cPanel Tech Support

    Submit a ticket | Check an existing ticket

  8. #8
    Registered User
    Join Date
    Aug 2011
    Posts
    2

    Default Re: Main site folder in public_html

    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.

Similar Threads & Tags
Similar threads

  1. public_html folder accidentally deleted
    By eveklc in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 04-19-2011, 11:37 AM
  2. Delete public_html folder
    By rongup in forum New User Questions
    Replies: 5
    Last Post: 04-17-2009, 11:35 AM
  3. can't move public_html folder back
    By breakaway in forum Data Protection
    Replies: 3
    Last Post: 04-02-2007, 11:49 AM
  4. Help: deleted public_html folder
    By doulosskm in forum Data Protection
    Replies: 4
    Last Post: 04-18-2006, 10:23 AM
  5. public_html folder missing
    By Markwaugh in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 12-20-2003, 11:01 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube