大网数据广告活动
服务器运维问答

Default directory for nginx?

· 52CE 我爱测

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 loc…

问题原文

原帖链接 · 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).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-09-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。