What is a docroot?

The web server document root (often referred to as the docroot) is the web server’s root directory; in other words, all pages it delivers are located in this directory and subdirectories of it. The path to your web server’s docroot depends on:

  • What operating system you’re using
  • The web server brand and version
  • Your hosting provider (if you use one)

This guide can’t cover all the possibilities, but we’ll help you get started figuring out where your docroot is. It’s important; your Magento 2 installation directory is a subdirectory of your web server’s docroot so if you don’t know where the docroot is, you’ll have a lot of trouble doing anything with Magento.

Look at the following sections in the order presented to locate your docroot.

Contact your hosting provider

If you use one, contact your hosting provider to locate the web server docroot. For example, cPanel typically uses public_html as its docroot but don’t believe us! Contact your provider directly.

Contact your network administrator

If you don’t use a hosting provider, you’re not technical, and you’re not that familiar with how things are set up, contact your network administrator.

Find the docroot yourself

This section is for technical people who don’t mind opening a command prompt and finding the docroot themselves.

This section assumes you have a simple web server setup with virtual hosts. An Apache virtual host refers to running more than one web site (such as company1.example.com and company2.example.com) on a single machine. A virtual host configuration can override the default docroot. For more information about virtual hosts, see Apache 2.2 or Apache 2.4 documentation.

To find the docroot:

  1. Find what operating system you’re using.
  2. Find your web server version:

    • Ubuntu: apache2 -v
    • CentOS: httpd -v
  3. See one of the following sections:

Find the docroot for Apache 2.2

To find the docroot for Apache 2.2:

  1. Log in to your Magento server.
  2. Open the following file in a text editor:

    • Ubuntu:

      /etc/apache2/sites-available/default
      
    • CentOS:

      /etc/httpd/httpd.conf
      
  3. Search the file for DocumentRoot. A typical result follows:

    • Ubuntu:

      DocumentRoot /var/www
      
    • CentOS:

      DocumentRoot /var/www/html
      

Find the docroot for Apache 2.4

This section applies to Apache 2.4 on Ubuntu only. If you installed Apache 2.4 on CentOS, consult the documentation provided with your version of Apache for more information.

To find the docroot for Apache 2.4:

  1. Log in to your Magento server.
  2. Open the following file in a text editor:

    /etc/apache2/sites-available/default/000-default.conf
    
  3. Search the file for DocumentRoot. A typical result follows:

    DocumentRoot /var/www/html