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.

Separate HTTP and HTPPS directories

Discussion in 'General Discussion' started by dsands, Oct 22, 2011.

  1. dsands

    dsands Member

    Joined:
    Oct 22, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    If I have an application on a dedicated server that requires separate directories for http and https, how is this configured in cPanel?

    On my current non-cPanel box the application has the following directory structure:
    /var/www/vhosts/domainname.com
    -- apps
    ---- app1
    ------ frontend
    ------ backend
    ---- app2
    ------ frontend
    -- config
    -- httpdocs
    ---- css
    ---- images
    ---- js
    -- httpsdocs
    ---- css
    ---- images
    ---- js

    Different parts of the app serve either http (frontend) or https (backend).

    It seems that cPanel forces you to put everything into public_html.

    Is there a way around this? I have root access.

    Thanks.
     
  2. PenguinInternet

    PenguinInternet Well-Known Member
    PartnerNOC

    Joined:
    Jun 20, 2007
    Messages:
    149
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Cardiff, UK
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    I assume that you've been using Plesk previously :) As far as I am aware, that is the only panel that does split it up. To be honest, there's not normally much of a requirement to split these up - you just have one set of website content and then access that via http or https as required. Far less complication with site design too.
     
  3. dsands

    dsands Member

    Joined:
    Oct 22, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Actually this is coming from a no-panel environment. There is only 1 file in httpdocs and 1 in httpsdocs... index.php serves as a front-controller for the app. So when you make a request for the frontend it routes through httpdocs... the backend routes through httpsdocs.

    It's currently in a subversion repo, so I'd like to just be able to check out the app into the domain root without jumping through hoops. The repo contains the directory structure mentioned above, which includes httpdocs and httpsdocs directories.
     
  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
    You might consider using secure.domain.com for the https content and then map the folder for secure to the https content. Since http and https content are not separated for cPanel, using a subdomain for the secure content would be the easiest way to separate them out.

    Alternatively, if you aren't against editing files manually, you could ensure the SSL is installed onto the domain in question in WHM, then go to /var/cpanel/userdata/username location where username is the account's cPanel username. There will be a domain.com_SSL file there with a line such as the following:

    Code:
    documentroot: /home/username/public_html
    Simply change the documentroot to whatever path you put the https files into, then run the following commands for it to take effect:

    Code:
    cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak111024
    /scripts/rebuildhttpdconf
    /etc/init.d/httpd restart
     
  5. dsands

    dsands Member

    Joined:
    Oct 22, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thanks Tristan for the reply.

    Is there any way at all to structure the directories like I described? The main reason for wanting to do this is because the repos have the apps set up this way.

    So installing the app is (on my old box) as simple as creating the domain, navigating to /var/www/vhosts/domain.com, and typing svn co http://pathtomyrepo.

    It creates the entire folder structure needed for the app.

    Even if this is very difficult in cPanel, I really need to get it done.

    I just hope it's not impossible in cPanel.
     
  6. 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
    If you create the actual directory structure, you could edit both /var/cpanel/userdata/username/domain.com and /var/cpanel/userdata/domain.com_SSL to use the documentroot and homedir paths you want.

    The normal settings are these:

    Code:
    documentroot: /home/username/public_html
    homedir: /home/username
    As such, if you want the homedir to be /var/www/vhosts/domain.com, then simply create the folder using "mkdir -p /var/www/vhosts/domain.com" for that site, change the homedir to that path, then change the documentroot to whatever folder should have http in it for the domain.com file.

    You will need to ensure to have the right ownership permissions on the folder of username:nobody for the top-level of the http folder (hhttpdocs) and username:username for the contents of that folder. Yes, it is going to be work, so you might want to try out a test account first before proceeding with doing it that way for your actual account.

    Of note, this is highly customized. While we can help with questions on the forum about this issue, this will not be something we can support in our ticketing system.
     
  7. dsands

    dsands Member

    Joined:
    Oct 22, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Exactly what I was looking for.

    I can keep the root under /home/username.

    I assume after making these changes cPanel will not overwrite them?

    Also, are the normal settings configurable somewhere? It would be REALLY nice to have cPanel create accounts with the directory structure I want.

    Thanks for your very prompt replies.
     
  8. 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
    You could set the homedir to somewhere else, but the documentroot is not configurable in WHM. The best option would be to modify the documentroot using a /scripts/postwwwacct script or hook so that this is changed after account creation.

    The only other option I could think would be to create a .local copy of /var/cpanel/templates/apache2/vhost.default (so it would be called vhost.local) and modify the path to what you want it to be there. Those local files override the existing default copies.
     
  9. dsands

    dsands Member

    Joined:
    Oct 22, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    That works for me.

    Thank you very much.
     
Loading...

Share This Page