Changing default home directory 'public_html'

Ramon Pego

Well-Known Member
Mar 12, 2019
62
11
8
Brazil
cPanel Access Level
Root Administrator
Twitter
Hello, I have read some topics here on how to change the root directory of my accounts.
I need it to be just 'public', instead of 'public_html'

I already read a topic that says to change in:
'/var/cpanel/userdata/USERNAME/DOMAIN.COM'
I did but he says after that I need rebuild the:
'/scripts/rebuildhttpdconf'
What do you mean by that?
beacuse did i change, restart apache and updated the browser and still did not change

And I wish everyone would be like this, from now on.

Topic

Thx.
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,301
363
Houston
Hello @Ramon Pego


First of all I want to point out that directory customization such as this is not something that cPanel supports. This means if you have issues with this customization our ability to provide assistance may be limited.

To clarify those instructions you'd need to run the following:

change this to what you need it to say:
Code:
documentroot: /home/USERNAME/public_html
Then run the following commands:

Code:
/scripts/updateuserdomains
/scripts/updateuserdatacache
mv /etc/apache2/conf/httpd.conf{,.bk}
/scripts/rebuildhttpdconf
/scripts/restartsrv_httpd
You should be able to copy/paste those in order to achieve the desired goal.


Thanks!
 
  • Like
Reactions: Ramon Pego

dem

Member
Jun 29, 2020
5
0
1
Philippines
cPanel Access Level
Root Administrator
hi, i tried doing this but upon running the scripts i'm receiving errors

sh /scripts/updateuserdomains
/scripts/updateuserdomains: line 8: use: command not found
/scripts/updateuserdomains: line 9: syntax error near unexpected token `('
/scripts/updateuserdomains: line 9: `use Cpanel::Userdomains::CORE ();
 

dem

Member
Jun 29, 2020
5
0
1
Philippines
cPanel Access Level
Root Administrator
i really did not change that much, i only modified the documentroot path, below is the config with the domain and username omitted.


---
customlog:
-
format: combined
target: /etc/apache2/logs/domlogs/[domain]
-
format: "\"%{%s}t %I .\\n%{%s}t %O .\""
target: /etc/apache2/logs/domlogs/[domain]-bytes_log
documentroot: /home/[username]/public_html/www/
group: [username]
hascgi: 1
homedir: /home/[username]
ip: [ipaddress]
owner: root
phpopenbasedirprotect: 1
phpversion: ea-php74
port: 8080
scriptalias:
-
path: /home/[username]/public_html/www/cgi-bin
url: /cgi-bin/
serveradmin: [email protected][domain]
serveralias: mail.[domain] www.[domain]
servername: [domain]
usecanonicalname: 'Off'
user: [username]
 

Ramon Pego

Well-Known Member
Mar 12, 2019
62
11
8
Brazil
cPanel Access Level
Root Administrator
Twitter
it looks like it might be something different, let's wait for someone from the staff to help you.
Do not forget that when it is resolved you must make the change to
Code:
'/var/cpanel/userdata/USERNAME/DOMAIN.COM_SSL'
too
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,301
363
Houston
hi, i tried doing this but upon running the scripts i'm receiving errors

sh /scripts/updateuserdomains
/scripts/updateuserdomains: line 8: use: command not found
/scripts/updateuserdomains: line 9: syntax error near unexpected token `('
/scripts/updateuserdomains: line 9: `use Cpanel::Userdomains::CORE ();
Why are you running this this way? You shouldn't need to use the sh command to run these. Literally just run:

Code:
/scripts/updateuserdomains
as the root user.
 

dem

Member
Jun 29, 2020
5
0
1
Philippines
cPanel Access Level
Root Administrator
btw, can i also specify a documentindex here? the problem here is my client have 2 domains pointed at the same folder but with each domain having it's own specific index file.
 

kamm

Well-Known Member
Jan 17, 2004
61
1
158
Spain
cPanel Access Level
Root Administrator
Hello @Ramon Pego


First of all I want to point out that directory customization such as this is not something that cPanel supports. This means if you have issues with this customization our ability to provide assistance may be limited.

To clarify those instructions you'd need to run the following:

change this to what you need it to say:
Code:
documentroot: /home/USERNAME/public_html
Then run the following commands:

Code:
/scripts/updateuserdomains
/scripts/updateuserdatacache
mv /etc/apache2/conf/httpd.conf{,.bk}
/scripts/rebuildhttpdconf
/scripts/restartsrv_httpd
You should be able to copy/paste those in order to achieve the desired goal.


Thanks!
I want to a change one user's webroot directory from public_html to public. Is this still the best way to achieve this?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,139
2,404
363
cPanel Access Level
Root Administrator
The method to make this change is still the same - here's a full guide on this work if you'd like to see that:

 
  • Like
Reactions: kamm

vincentg

Well-Known Member
May 12, 2004
177
5
168
new york
I can't seem to see a reason to change the default directory structure.
Can someone tell me why anyone would want to do this?
 

kamm

Well-Known Member
Jan 17, 2004
61
1
158
Spain
cPanel Access Level
Root Administrator
@vincentg : The PHP framework Laravel uses public instead of public_html for it's web-root. It used to be quite difficult to change this from within Laravel, so (for me) it was easier to change it in cPanel.
 

vincentg

Well-Known Member
May 12, 2004
177
5
168
new york
I haven't used it before but looking into it I find it is an install from Softaculous if you have it.

And to make Laravel project files publicly available, you must create a symbolic link in the public_html folder that points to public folder.

That would be a better way as messing with the cpanel structure may cause unknown problems.