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

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

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


当前回答

对于CentOS、Ubuntu和Fedora,默认目录为/usr/share/nginx/html

其他回答

Alpine Linux根本没有任何默认位置。文件/etc/nginx/conf.d/default.conf说:

# Everything is a 404
location / {
    return 404;
}

# You may need this to prevent return 404 recursion.
location = /404.html {
    internal;
}

替换成像root /var/www/localhost/htdocs这样的一行来指向你想要的目录。然后sudo service nginx restart重新启动。

我在Ubuntu上的nginx是“nginx version: nginx/1.9.12 (Ubuntu)” 根路径为/var/www/html/

Ubuntu信息是: 没有LSB模块可用。 分销商ID: Ubuntu 描述:Ubuntu 16.04 LTS 版本:16.04 代号:主客关系的

实际上,如果你只是在Ubuntu上安装了nginx,那么你可以去“/etc/nginx/sites-available”并检查默认文件,有一个类似于“root/ web/root/path/goes/here”的配置。这就是你要找的。

nginx的默认web文件夹取决于你如何安装它,但通常它在这些位置:

/usr/local/nginx/html
/usr/nginx/html

在Ubuntu中, Nginx默认根目录位置为/usr/share/nginx/html

如果你使用的是Ubuntu 14.04,你可以在以下路径找到nginx www目录:

yusuf@yusuf-he:/usr/share/nginx/html$ pwd
/usr/share/nginx/html
yusuf@yusuf-he:/usr/share/nginx/html$