one document root, best way to do this?
Hello everyone,
English is not my mother language, so if my question is unclear, please say so.
I want to reinstall my VPS in a better way than it is right now. What I want to accomplish is that all (new) domains when I add them, automatically point to the same document root (the same folder).
How do I do this now? I use one "main" user. I use this user to log in to cPanel and when I add a new domain I add it as an "add-on domain". This way I can point all add-on domains to the same document root.
However, Im wondering if there is somehow a better solution to accomplish this. I'd rather add each domain as a "normal" domain, instead of an add-on domain.
Is there a solution to do this? For example change a default vhost template or something?
Actually it should be like this. I log in to WHM as root. Then when I create a user, the document root of this user should always be the same. Can it be done?
Once again, if my question is unclear, please say so!
-
You can create separate user for each domains from WHM Home "Account Functions "Create a New Account 0 -
[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 -
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 -
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 -
[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 -
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 -
The changes are preserved. It's okay to edit those files to modify the document root. Thank you. 0 -
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 -
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 -
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 -
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 -
I'd rather try the template approach... but I wonder which template exactly I have to modify, and how... any advice on that? 0 -
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 -
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 -
[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 -
So what you're saying is whenever I update Apache I also must update the local vhost? 0 -
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 -
Ok thanks Michael, I think I understand now. 0
Please sign in to leave a comment.
Comments
18 comments