cPanel & WHM Version 114 has been released, and brings a slew of great updates. Take a look at what is included, and then upgrade today!

Get docroot easily via hooks

Feature Importer shared this idea 11 years ago
Needs Review

As a Developer, I want to get docroot easily via hooks, so that I don't have to store a hash or know a user's password.

Presently if you are using hooks in cPanel&WHM getting the docroot of an account is a pain. In fact some resort to directly reading cache files (which is not recommended) as a means of doing this. However there are many scenarios where knowing an account's docroot can be very useful.

Yes this data can be accessed via the APIs but that would require either storing a hash in a place users can read it (a security risk) or knowing the user's password (not advised).

As a result an easier way to get an account's docroot easily from code executing in a hook is desired.

This is a feature that has been migrated over from the cPanel Forums. All previous comments and discussions concerning this feature can be located at:

Replies (2)


This should be able to be retrieved from the /usr/local/apache/conf/httpd.conf using the unix utilities grep and awk, which is what I do all the time.

grep -A5 -E "Server(Name|Alias).*\ $domain" /usr/local/apache/conf/httpd.conf | awk '/DocumentRoot/ {print $2}' | head -1

I would suggest a shell hook in your application would get this information just fine. Alternatively you could read the /etc/userdatadomains where this should also be stored.

sed 's/=/ /g' /etc/userdatadomains | awk "/^$domain/"'{print $6}'


Due to the age of this request and limited upvotes, I have marked it as Not Planned. Changes in future interest could warrant re-opening the request.

Leave a Comment
Attach a file