问题原文
原帖链接 · coding4fun · CC BY-SA 4.0
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?
社区高分解答
原帖链接 · womble · CC BY-SA 4.0
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).
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
