Skip to main content

one document root, best way to do this?

Comments

18 comments

  • iserversupport
    You can create separate user for each domains from WHM Home "Account Functions "Create a New Account
    0
  • ozzieonline
    [quote="iserversupport, post: 1684912">You can create separate user for each domains from WHM Home "Account Functions "Create a New Account
    Thanks for replying. I understand what you are saying, but my question is... can I somehow point EACH domain to the same document root (folder). So when I create a new account and a new domain for John, I want the document root to be folder X. Then when I create a new account and a new domain for Mike, I want the document root to be this same folder X. Is that possible?
    0
  • cPanelMichael
    Hello :) You can modify the document root for a domain name by editing the "documentroot" entry in the appropriate cPanel user data file: /var/cpanel/userdata/$username/$domain.com
    Then, rebuild the Apache configuration file via: /scripts/rebuildhttpdconf
    However, if you want all domain names to have the same document root upon account creation, then you may want to modify the Apache templates per the instructions here: Apache - Custom Templates Thank you.
    0
  • ozzieonline
    Thanks Michael! Doesn't this file "/var/cpanel/userdata/$username/$domain.com" get changed on cPanel/WHM/Apache updates? Will my adjustments be forever preserved? I once did some tweaking of the Apache templates to find out a whole lot later that some of my adjustments disappeared due to a software update :-s Well ehhh... the link you gave me says: [QUOTE]"he subdirectories within the /var/cpanel/userdata/ directory contain files that are in YAML format. Warning: Do not manually edit these YAML files.
    0
  • Infopro
    [QUOTE]I once did some tweaking of the Apache templates to find out a whole lot later that some of my adjustments disappeared due to a software update
    That shouldn't have happened.
    0
  • ozzieonline
    Correct, shouldn't have... but it did. But is what I want possible? cPanelMichael told me to change /var/cpanel/userdata/$username/$domain.com, but the manual warns that these files should not be changed... so that's strange isn't it?
    0
  • cPanelMichael
    The changes are preserved. It's okay to edit those files to modify the document root. Thank you.
    0
  • ozzieonline
    Thanks Michael. My last question... how would I do this server-wide. So not domain-based. So when I add a new domain (from different users) the document root is always the same. What's the best way to accomplish that, without the risk my adjustments are being overwritten?
    0
  • cPanelMichael
    Here is a quote from my previous response: [QUOTE]However, if you want all domain names to have the same document root upon account creation, then you may want to modify the Apache templates per the instructions here: Apache - Custom Templates
    Thank you.
    0
  • ozzieonline
    Well, I tried that before but could not accomplish it. So that's why I was hoping you could give me some good advice which file to change and how.
    0
  • cPanelMichael
    You could also setup a post account creation hook that modifies the "documentroot" value in the /var/cpanel/userdata/$username/$domain.com file after the account is created. Information on script hooks is available at: Script Hooks - Intro You may want to consult with a software developer if you need the full script developed for you. Thank you.
    0
  • ozzieonline
    I'd rather try the template approach... but I wonder which template exactly I have to modify, and how... any advice on that?
    0
  • cPanelMichael
    You want it to apply to all VirtualHosts, so this part of the document I provided: Custom Templates That Will Apply To All VirtualHosts Note that you may need to consult with a system administrator for assistance if you are not comfortable making such custom changes. Thank you.
    0
  • ozzieonline
    I understand I'll have to use a local version of te vhost, but what if cPanel updates and changes the default vhost (on which my local version is based). Will things go wrong then because my local vhost is not up to date anymore? Or is that impossible?
    0
  • cPanelMichael
    [quote="ozzieonline, post: 1694751">I understand I'll have to use a local version of te vhost, but what if cPanel updates and changes the default vhost (on which my local version is based). Will things go wrong then because my local vhost is not up to date anymore? Or is that impossible?
    The template is connected to the version of Apache, so that's not going to be an issue. You could always just complete the process over again in the event you upgrade to a newer version. Thank you.
    0
  • ozzieonline
    So what you're saying is whenever I update Apache I also must update the local vhost?
    0
  • cPanelMichael
    No, if you change the version of Apache installed on your system, you must make the change to the template relative to the version of Apache installed. There are different paths to the template, depending on the version of Apache installed, as listed in the documentation. Thank you.
    0
  • ozzieonline
    Ok thanks Michael, I think I understand now.
    0

Please sign in to leave a comment.