# Finding docroot directory?

**URL:** <https://www.ruby-forum.com/t/finding-docroot-directory/228922>\
**Category:** NGINX\
**Created:** [May 13, 2013, 12:56pm UTC](https://www.ruby-forum.com/t/finding-docroot-directory/228922 "2013-05-13T12:56:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shohreh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@Shohreh](https://www.ruby-forum.com/u/Shohreh)\
**Post date:** [May 13, 2013, 12:56pm UTC](https://www.ruby-forum.com/t/finding-docroot-directory/228922/1 "2013-05-13T12:56:51Z")

</div>

Hello

I’m running Nginx 1.4.1 on an appliance running Debian 6, and can’t find  
from which directory Nginx is serving files.

According to /etc/nginx.conf, the location for “/” is “root  
/var/www;”,  
but even renaming the default index.html still displays the familiar  
“Welcome to nginx!”.

After using “apt-get upgrade” to upgrade from 1.2.? to 1.4.1, I ran  
“/etc/init.d/nginx restart” just in case, but it made no difference.

Is there a way to have Nginx tell from where it’s serving files?

Thank you.

Posted at Nginx Forum:

> **[\[1.4.1\] Finding docroot directory?](https://forum.nginx.org/read.php?2,239114,239114#msg-239114)**
>
> Hello I'm running Nginx 1.4.1 on an appliance running Debian 6, and can't find from which directory Nginx is serving files. According to /etc/nginx.conf, the location for "/" is "root /var/www;", but even renaming the default...

---

<div class="post-metadata">

**Author:** ![Shohreh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@Shohreh](https://www.ruby-forum.com/u/Shohreh)\
**Post date:** [May 13, 2013, 1:02pm UTC](https://www.ruby-forum.com/t/finding-docroot-directory/228922/2 "2013-05-13T13:02:42Z")

</div>

I found a work-around: Reading “/var/log/nginx/error.log” includes a  
warning  
that Nginx can’t find “/usr/share/nginx/html/favicon.ico”, so for some  
reason, Nginx uses /usr/share/nginx/html/ instead of /var/www.

I’m confused about the multiple configuration files used by Nginx:

/etc/nginx.conf  
/etc/conf.d/  
/etc/sites-available/  
/etc/sites-enabled/

Why are there more than one?

Thank you.

Posted at Nginx Forum:

> **[Re: \[1.4.1\] Finding docroot directory?](https://forum.nginx.org/read.php?2,239114,239115#msg-239115)**
>
> Hello I'm running Nginx 1.4.1 on an appliance running Debian 6, and can't find from which directory Nginx is serving files. According to /etc/nginx.conf, the location for "/" is "root /var/www;", but even renaming the default...

---

<div class="post-metadata">

**Author:** ![Shohreh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@Shohreh](https://www.ruby-forum.com/u/Shohreh)\
**Post date:** [May 13, 2013, 1:07pm UTC](https://www.ruby-forum.com/t/finding-docroot-directory/228922/3 "2013-05-13T13:07:23Z")

</div>

This Ars Technica article is where I learned how to use nginx. Lee  
Hutchinson does a good job explaining all that.

> **[How to set up a safe and secure Web server](https://arstechnica.com/gadgets/2012/11/how-to-set-up-a-safe-and-secure-web-server/)**
>
> Learn a lot by doing it yourself instead of going with a hosting company.

---

<div class="post-metadata">

**Author:** ![Shohreh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@Shohreh](https://www.ruby-forum.com/u/Shohreh)\
**Post date:** [May 13, 2013, 1:19pm UTC](https://www.ruby-forum.com/t/finding-docroot-directory/228922/4 "2013-05-13T13:19:05Z")

</div>

On Mon, May 13, 2013 at 06:56:11AM -0400, Shohreh wrote:

Hi there,

> I’m running Nginx 1.4.1 on an appliance running Debian 6, and can’t find  
> from which directory Nginx is serving files.

If “nginx -V” doesn’t tell you, and the log files don’t tell you, then  
you can do something like

location = /docroot-test {  
return 200 “docroot is $document\_root\n”;  
}

followed by

curl -i [http://localhost/docroot-test](http://localhost/docroot-test)

You’ll need to make sure that the new location{} is in the server{}  
that will handle this request, of course, but it’s hard to argue with  
asking the server itself what directory it is looking in.

Any _other_ location{} block might have a different “root” or “alias”  
defined, but that should be clear from the config file.

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Shohreh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@Shohreh](https://www.ruby-forum.com/u/Shohreh)\
**Post date:** [May 13, 2013, 1:25pm UTC](https://www.ruby-forum.com/t/finding-docroot-directory/228922/5 "2013-05-13T13:25:31Z")

</div>

On Mon, May 13, 2013 at 07:02:14AM -0400, Shohreh wrote:

Hi there,

> I’m confused about the multiple configuration files used by Nginx:
> 
> /etc/nginx.conf  
> /etc/conf.d/  
> /etc/sites-available/  
> /etc/sites-enabled/
> 
> Why are there more than one?

nginx uses exactly one – the one named in the “-c” argument when run,  
or else the compiled-in value.

That one file may use the “include” directive to read in other files,  
if the administrator thinks that this is more useful to them.

And if you’re not running the equivalent of  
“/usr/local/nginx/sbin/nginx”,  
then whatever startup sequence you are running might introduce its own  
“-c” argument. That’s up to the administrator, and not nginx.

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Shohreh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@Shohreh](https://www.ruby-forum.com/u/Shohreh)\
**Post date:** [May 13, 2013, 1:42pm UTC](https://www.ruby-forum.com/t/finding-docroot-directory/228922/6 "2013-05-13T13:42:28Z")

</div>

Thanks everyone for the infos. “nginx -V” doesn’t say where the docroot  
is,  
but I noticed that /etc/nginx/nginx.conf does use  
“/etc/nginx/conf.d/\*.conf”, where default.conf says:

```auto
location / {
        root /usr/share/nginx/html
```

Thank you.

Posted at Nginx Forum:

> **[Re: \[1.4.1\] Finding docroot directory?](https://forum.nginx.org/read.php?2,239114,239131#msg-239131)**
>
> Hello I'm running Nginx 1.4.1 on an appliance running Debian 6, and can't find from which directory Nginx is serving files. According to /etc/nginx.conf, the location for "/" is "root /var/www;", but even renaming the default...
