What is a Document Root folder?

Sharing is caring!

The document root folder is the root folder of your site.

For Ubuntu servers it’s in /var/www/html and is owned by www-data user.

For other sites that are hosted on the server it’s usually one of these:

  • www
  • public_html
  • htdocs
  • httpdocs or httpsdocs
  • etc

The document root folder may or may not necessarily be the one where WordPress is installed because it can be installed in different folders. It really depends on the context or your software.

This folder is important because there are stores the files of your site that are supposed to be accessed.

If you have some important files do move them in a folder that’s one level above the document root folder for security reasons.

Apache web server defines the document root folder as

DocumentRoot /var/www/vhost/example.com/htdocs

With nginx you can just add

root /var/www/vhost/example.com/htdocs;

If you’re using some sort of control panel such as cPanel or other you have to make sure that your addon domains are outsite of your main site’s document root directory otherwise their private and non-public files may be accessible.

Sharing is caring!

Leave a Comment

Your email address will not be published. Required fields are marked *