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

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

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


当前回答

对于nginx/1.4.6 (Ubuntu)

/etc/nginx$ cat /etc/nginx/sites-available/default | grep -i root
- root /usr/share/nginx/html;

其他回答

需要注意的是,nginx服务器的默认索引页面也会显示根位置。从Amazon Linux AMI上的nginx(1.4.3),您可以得到以下内容:

这是默认的index.html页面,在Amazon Linux AMI上与nginx一起分发。它位于/usr/share/nginx/html。

你现在应该把你的内容放在你选择的位置,并编辑nginx配置文件/etc/nginx/nginx.conf中的根配置指令

如果你是通过homebrew安装的,并且你使用的是macOS,你可以在/opt/homebrew/Cellar/nginx/1.23.2/html找到它,用你的版本替换1.23.2。

在Mac上使用brew安装nginx:

/ usr / local / etc / nginx / nginx上。

location / { 
    root   html;  # **means /usr/local/Cellar/nginx/1.8.0/html and it soft linked to /usr/local/var/www**
    index  index.html;
}  

在Mac OS X上,使用brew安装nginx会使默认目录:

/usr/local/var/www

So:

root html

意味着

root /usr/local/var/www/html

没有html目录,所以必须手动创建。

对于nginx/1.4.6 (Ubuntu)

/etc/nginx$ cat /etc/nginx/sites-available/default | grep -i root
- root /usr/share/nginx/html;