Where Is Nginx Document Root

Where Is Nginx Document Root

What Is Nginx?

Nginx is an open source, high-performance web server and reverse proxy software popular on Linux and Unix. It is used to serve static content quicker than Apache. Nginx also provides the ability to host multiple websites on a single server. It’s fast, reliable and very lightweight when compared to other web servers.

Nginx has many features that make it popular, such as support for HTTP/2, dynamic modules, and reverse proxy capabilities. Its reverse proxy capabilities allow it to work as a load balancer, allowing it to be used as an all-in-one web server/load balancer/reverse proxy solution.

What Is a Document Root?

The document root is the top-level directory of the web server from which web pages are served. The server uses the root directory to find the files and directories it needs to serve the web pages requested by users. The document root typically contains static content such as HTML files, images, CSS, JavaScript and other media.

The document root is also where web applications are stored, since they often rely on accessing files in this specific directory. The document root can also be referred to as the web root or the public HTML directory. The document root is usually called “document_root” on web hosting services.

What Is the Document Root for Nginx?

The default document root for Nginx is /var/www/html. This is where all of the static content and web application files for a web site are stored. The web server looks in the root directory for the files and directories it needs to serve web pages.

The document root can be changed by altering the Nginx configuration file. This can be done to use a different directory structure if desired. It’s also possible to configure multiple web sites on one server, and have each site use a different document root.

Are There Different Types of Document Root for Nginx?

Yes, there are different types of document root for Nginx. Nginx supports two different types of document roots: global and local. Global document roots are the default document root that is used for every virtual host. Local document roots, meanwhile, are used only for individual virtual hosts. This allows different virtual hosts to use different document roots for their content.

How To Set a Document Root for Nginx?

Setting up a document root for Nginx is a straightforward process. First, decide on which directory should be used as the document root, and make sure it exists. The document root can be changed in the Nginx configuration file, which is typically located at /etc/nginx/nginx.conf.

Next, edit the configuration file and find the server block for the virtual host you’re working with. Inside the server block, look for the root directive. This directive sets the document root for the virtual host, and needs to be changed to the desired path. Once you have made the changes, save and close the configuration file. Then, restart the Nginx web server to make sure the changes take effect. If everything is correct, Nginx should now be using the new document root.


Nginx is a popular web server and reverse proxy software used by many websites and services. It’s important to be familiar with how Nginx works, especially the concept of the document root. Nginx’s document root by default is /var/www/html, but it can be changed by altering the Nginx configuration file. Additionally, Nginx supports both global and local document roots, allowing each virtual host to use its own document root if needed.

Thank You for Reading This Article

Be sure to check out our other articles for more information about Nginx.


  • Q: Where is the Nginx document root?
  • A: The default Nginx document root is /var/www/html.
  • Q: Can I change the document root?
  • A: Yes, you can change the document root by editing the Nginx configuration file.
  • Q: Does Nginx support local document roots?
  • A: Yes, Nginx supports both global and local document roots.

Leave a Reply

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