Skip to main content

Changing default home directory 'public_html'

Comments

17 comments

  • cPanelLauren
    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: documentroot: /home/USERNAME/public_html
    Then run the following commands: /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!
    0
  • Ramon Pego
    I'm very sorry for the delay, this worked great for me, i can made this change for the future created users?
    0
  • cPanelLauren
    Hi @Ramon Pego If you need to yes, it should be fine, though we are going to be introducing the ability to customize the homedir in a future release of cPanel/WHM
    0
  • dem
    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 ();
    0
  • Ramon Pego
    Hi @dem its probably when you edit your user domain file, you wrote something wrong, or erased some character without seeing if its possibie show us your domain config file hide your private info if needed
    0
  • dem
    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: webmaster@[domain] serveralias: mail.[domain] www.[domain] servername: [domain] usecanonicalname: 'Off' user: [username]
    0
  • Ramon Pego
    try remove the slash at the end in documentroo documentroot: /home/[username]/public_html/www/
    documentroot: /home/[username]/public_html/www
    0
  • dem
    try remove the slash at the end in documentroo documentroot: /home/[username]/public_html/www/
    documentroot: /home/[username]/public_html/www

    i tried this and it has the same error
    0
  • Ramon Pego
    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 '/var/cpanel/userdata/USERNAME/DOMAIN.COM_SSL'
    too
    0
  • cPanelLauren
    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: /scripts/updateuserdomains
    as the root user.
    0
  • dem
    Why are you running this this way? You shouldn't need to use the sh command to run these. Literally just run: /scripts/updateuserdomains
    as the root user.

    Thank you, this worked. I was thinking it was a bash file, sorry about that.
    0
  • dem
    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.
    0
  • kamm
    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: documentroot: /home/USERNAME/public_html
    Then run the following commands: /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?
    0
  • cPRex Jurassic Moderator
    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:
    0
  • vincentg
    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?
    0
  • kamm
    @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.
    0
  • vincentg
    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.
    0

Please sign in to leave a comment.