change the primary domain's web root

gmedia01

Registered
Aug 24, 2012
4
0
1
cPanel Access Level
Reseller Owner
I have access to cPanel and WHM on our dedicated server.
In cPanel one particular domain is treated as a primary domain and others as addon domains. That primary domain's web root is "/public_html". We can add more domains and can choose any directory as their root. But don't seem to be able to change primary domain's web root.

I want to change the primary domain's web root. How do I do that? My server support guy said I'd have to do it through SSH (Linux command line).

Please tell me there is a way to do this without knowing Linux.

Also, for all of those with the "why," I want all domains to have their own folder inside the public_html folder as apposed to inside the first (main) website's folder. I don't want to see any other site folders when I'm editing the main site via FTP and risk deleting sites just from a mis-click or something. I've done it before :( When you look at code and stuff for a long time, things can start to blend. You know? Also, coders an be (probably should be) anal too, so they want things to be a certain way.

THANK you for your time!

Chris
 
Last edited:

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Re: Change directory of Main Domain

Hello Chris,

There is not a way to change it without knowing SSH. This is set in /var/cpanel/userdata/username/maindomain.com file. If you want to change the documentroot there, you'd revise the /home/username/public_html line and then run the following commands to update Apache's configuration:

Code:
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak120824
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
You might consider posting a feature request for the main domain to be configurable for a different path during account creation. That would be at Feature Requests for cPanel & WHM for new feature requests.

Thanks!
 

charsleysa

Active Member
Jul 18, 2011
41
0
56
Palmerston North, New Zealand
cPanel Access Level
Root Administrator
Re: Change directory of Main Domain

gmedia01, I am curious as to why you want all domains to have their own folders inside /home/<username>/public_html/ instead of /home/<username>/
The latter seems to be a better alternative as you don't have to deal with another tier in the directory tree.
Also note that addon domains don't have to be placed in public_html, they can be placed inside any folder in /home/<username>/
 

gmedia01

Registered
Aug 24, 2012
4
0
1
cPanel Access Level
Reseller Owner
Re: Change directory of Main Domain

gmedia01, I am curious as to why you want all domains to have their own folders inside /home/<username>/public_html/ instead of /home/<username>/
The latter seems to be a better alternative as you don't have to deal with another tier in the directory tree.
Also note that addon domains don't have to be placed in public_html, they can be placed inside any folder in /home/<username>/
Did you read the other half of my original post? Does that answer your question?

Thanks!

Chris

- - - Updated - - -

Hello Chris,

There is not a way to change it without knowing SSH. This is set in /var/cpanel/userdata/username/maindomain.com file. If you want to change the documentroot there, you'd revise the /home/username/public_html line and then run the following commands to update Apache's configuration:

Code:
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak120824
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
You might consider posting a feature request for the main domain to be configurable for a different path during account creation. That would be at Feature Requests for cPanel & WHM for new feature requests.

Thanks!
I am concerned that you are right. I saw a post back in 2009 that asked the same thing and someone replied that it would be "fixed" or added in the next release. Three years later....

Well, I definitely don't know SSH. I don't even know where to access it. I'll snoop around WHM...

Thanks for the help!

Chris
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Re: Change directory of Main Domain

If you cannot learn SSH, then you might want to hire someone, because you will need someone to manage the server who knows SSH at some point. You cannot do everything with a control panel frontend.

Here's a catalog of system administrators and developers:

Sys Admin Services | cPanel App Catalog
 

charsleysa

Active Member
Jul 18, 2011
41
0
56
Palmerston North, New Zealand
cPanel Access Level
Root Administrator
Re: Change directory of Main Domain

Did you read the other half of my original post? Does that answer your question?

Thanks!

Chris

- - - Updated - - -



I am concerned that you are right. I saw a post back in 2009 that asked the same thing and someone replied that it would be "fixed" or added in the next release. Three years later....

Well, I definitely don't know SSH. I don't even know where to access it. I'll snoop around WHM...

Thanks for the help!

Chris
Sorry it only partially answers my question because with your way you are just creating more hassle for yourself when a solution for what you want to do is already available without have to do anything in SSH, all you have to do is put the folders inside /home/<username>/ instead of /home/<username >/public_html/ and leave the main domain inside public_html
 

mgrant

Registered
May 4, 2013
4
0
1
cPanel Access Level
Reseller Owner
Re: Change directory of Main Domain

Stefan,

I ran across this thread trying to understand what the correct way was to host multiple domains out of a single cpanel account.

Imagine you want to host domain1.com and domain2.com. So you create an account in cPanel, probably you start with domain1.com. This domain ends up in public_html/. You then do an add-on domain and now where do you put this domain? in public_html_domain2/? It's a bit messy.

I see 2 possible solutions:

1) create a second tier inside public_html as in public_html/domain1.com/ and public_html/domain2.com, or
2) instead of creating /home/user/public_html, create /home/user/domain1.com/

I would like to see a template which I could use $domain to create these folders, for example, I'd like to configure either public_html or $domain.

Michael Grant
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
Re: Change directory of Main Domain

Imagine you want to host domain1.com and domain2.com. So you create an account in cPanel, probably you start with domain1.com. This domain ends up in public_html/. You then do an add-on domain and now where do you put this domain? in public_html_domain2/? It's a bit messy.

I see 2 possible solutions:

1) create a second tier inside public_html as in public_html/domain1.com/ and public_html/domain2.com, or
2) instead of creating /home/user/public_html, create /home/user/domain1.com/
The field for the directory where addon domains store their files is automatically populated as public_html/$domain. Could you elaborate a bit more on the differences you would like to see based on what is already in-place with the existing system?

Thank you.
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,607
80
458
cPanel Access Level
Root Administrator
Accidentally deleting a directory is a human problem, not a technology problem. Technology can provide some safeguards (e.g. backup for restoration) but cannot ultimately prevent or solve the human problem. Moving the directory to a sub directory because a person might accidentally delete the directory will not solve the problem.

As for myself, I leave my primary domain in /home/user/public_html; and place my additional domains like:

/home/user/domains/example.com
/home/user/domains/example.net

I do the same for sub domains.

I suppose if one frequently creates domains, having to change the document root form field every time would be annoying. For those I suppose a user-preference 'where should the default document root be suggested' would be helpful.