我以前使用过Apache,所以我知道默认的公共web根目录通常是/var/www/。

我最近开始使用nginx,但我似乎找不到默认的公共web根。

我在哪里可以找到nginx的默认公共web根?


当前回答

对于Ubuntu和docker映像:

 /usr/share/nginx/html/

其他回答

转储配置:

$ nginx -T
...
server {
    ...
    location / {
        root   /usr/share/nginx/html;
        ...
    }
    ...
}

你得到的可能是不同的,因为它取决于你的nginx是如何配置/安装的。

引用:

-T选项 -T选项

更新:关于是否/何时将-T选项添加到nginx的问题有一些混淆。vl-homutov于2015年6月16日在手册页中记录了它,这成为v1.9.2发行版的一部分。甚至在发行说明中也提到了。自那以后,t选项出现在每个nginx版本中,包括Ubuntu 16.04.1 LTS上可用的版本:

root@23cc8e58640e:/# nginx -h    
nginx version: nginx/1.10.0 (Ubuntu)
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/share/nginx/)
  -c filename   : set configuration file (default: /etc/nginx/nginx.conf)
  -g directives : set global directives out of configuration file

你可以访问nginx文件配置,你可以看到root /path。在这个 nginx apache的默认地址是/var/www/html

导航到文件 $ cat /etc/nginx/nginx.conf

在HTTP——>服务器——>根下的文件中

在这里,您将看到根目录的默认位置和所有错误页面。

如果在Ubuntu上使用apt-get安装,请尝试/usr/share/nginx/www.

编辑:

在最近的版本中,路径已更改为: /usr/share/nginx/html

2019编辑:

你也可以试试/var/www/html/index.nginx-debian.html。

运行nginx -V命令,查找——前缀。使用该条目定位默认路径。