How To: Easily Find a Domain Document Root Folder in cPanel (script)

  Control Panel, Tools

In cPanel server it may take some time to find a Domain Document Root Folder, especially if it is an AddOn domain or a Subdomain.

There is a script, which allows to find the path immediately. For example:

[cc][root@sme11 ~]# we tirs.com.my
tirs.com.my
/home/tirscommy/public_html[/cc]

or subdomain:

[cc][root@sme11 ~]# we test.tirs.com.my
test.tirs.com.my
/home/tirscommy/public_html/test[/cc]

The script is as below:

[cc][root@sme11 ~]# cat /sbin/we

#!/bin/bash
domain=$1;

domain=`echo $domain | tr A-Z a-z`;

C_GREEN=’\033[0;32m’
C_RED=’\033[0;31m’
C_RESET=’\033[0m’

echo -e $C_RED $domain $C_RESET;

PATH=`cat /usr/local/apache/conf/httpd.conf |awk ‘/www.’$domain’/,/VirtualHost/ {print}’ |grep DocumentRoot |awk ‘{print $2}’`;
echo -e $C_GREEN “$PATH” $C_RESET;[/cc]

The script is available for all SME servers, if you didn’t find it please help to install it – just copy the script to /sbin/we file and change file permissions to 755.