DEV Community

Pradeep Kumar
Pradeep Kumar

Posted on • Edited on

How to change CPanel account root directory.

Step 1

Update variable documentroot in following two file:

sudo nano /var/cpanel/userdata/<cpanel-username>/<example.com>
sudo nano /var/cpanel/userdata/<cpanel-username>/<example.com>_SSL
Enter fullscreen mode Exit fullscreen mode

Replace <example.com> to your actual domain.

You need update following line in both files:

documentroot: /home/<cpanel-username>/public_html
Enter fullscreen mode Exit fullscreen mode

to your target folder.

Eg:

documentroot: /home/<cpanel-username>/public_html/public
Enter fullscreen mode Exit fullscreen mode

Step 2

Then edit:

sudo nano /var/cpanel/userdata/<cpanel-username>/<example.com>.php-fpm.yaml
Enter fullscreen mode Exit fullscreen mode

and add following line

php_admin_value_doc_root: { name: 'php_admin_value[doc_root]', value: /home/<cpanel-username>/public_html/public }
Enter fullscreen mode Exit fullscreen mode

Final file will look like:

---
_is_present: 1
php_admin_value_doc_root: { name: 'php_admin_value[doc_root]', value: /home/<cpanel-username>/public_html/public }
Enter fullscreen mode Exit fullscreen mode

Step 3

Then to rebuild the Apache conf and restart Apache:

/scripts/php_fpm_config --rebuild
/scripts/rebuildhttpdconf

/scripts/restartsrv_apache_php_fpm
/scripts/restartsrv_httpd
service httpd restart
Enter fullscreen mode Exit fullscreen mode

When you visit your url and getting following message:

No input file specified
Enter fullscreen mode Exit fullscreen mode

Simply restart the server, it should be fixed.

Top comments (0)