7

I have ubuntu 15.04. After searching I found a variety of links that suggest the default directory for nginx is /usr/share/nginx/html. It looks like that directory was created and there was already an index.html file at that location. I tried to add another html file and found that I could not browse to that location. I then found another links suggesting /var/www/html which I also created a test html file and was able pull back the file. Why do both directories exist and what is the difference between them?

2
  • Anything under /usr would not typically be modifiable by normal users (eg. www-data). /var/www/html would make more sense. I can't speak specifics though because I typically compile nginx from source where the default is /var/nginx/html. The Ubuntu nginx tends to be horribly out of date even in current releases.
    – CR.
    Sep 2, 2015 at 3:17
  • Please go through older post unix.stackexchange.com/questions/110328/… Hope it would helpful. Aug 10, 2018 at 5:18

2 Answers 2

8

Both directories exist because both are needed, for different purposes.

/usr/share/nginx/html is the compiled-in default location for each server's document root, in the absence of one being specified.

/var/www/html is the configured location for the default server's document root as configured in /etc/nginx/sites-available/default.

Why use /var/www/html? Because a sysadmin may wish to modify the default vhost's document root, but the Filesystem Hierarchy Standard (which Ubuntu follows because it follows Debian, whose policy requires compliance with the FHS) requires that user-modifiable content go into /var (or /srv, or /home -- basically any number of places that aren't /usr).

-1

You need to open default vhost file (usually /etc/nginx/sites-enabled/default) and check the 'root' parameter. It points to root directory for default nginx vhost.

Also, you may need to change permissions to your html page.

chown www-data:www-data /path/to/your/html/page.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .