我以前使用过Apache,所以我知道默认的公共web根目录通常是/var/www/。
我最近开始使用nginx,但我似乎找不到默认的公共web根。
我在哪里可以找到nginx的默认公共web根?
我以前使用过Apache,所以我知道默认的公共web根目录通常是/var/www/。
我最近开始使用nginx,但我似乎找不到默认的公共web根。
我在哪里可以找到nginx的默认公共web根?
当前回答
如果在Ubuntu上使用apt-get安装,请尝试/usr/share/nginx/www.
编辑:
在最近的版本中,路径已更改为: /usr/share/nginx/html
2019编辑:
你也可以试试/var/www/html/index.nginx-debian.html。
其他回答
你可以访问nginx文件配置,你可以看到root /path。在这个 nginx apache的默认地址是/var/www/html
如果你需要找到编译时定义的nginx公共根文件夹,你可以检查你的access.log文件。
打开nginx.conf 找到log_format指令 log_format的值是一个模板字符串,用于将信息写入access.log文件。您可以在这个模板字符串中添加$document_root变量,以将默认的www根位置记录到文件中。
下面是来自nginx.conf的http部分的一个例子,修改了log_format指令,$document_root被添加在字符串的开头:
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
## ADD $document_root HERE ##
log_format main '$document_root $remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
etc. .......
然后备份conf.d目录下的所有配置文件*.conf,并创建配置文件test.conf,如下所示: 服务器{ 听80; server_name主机; } 在“/etc/hosts”文件中增加如下一行:127.0.0.1 localhost 重载nginx配置:nginx -s重载 发送GET请求到http://localhost: curl http://localhost 查看access.log的最后一个字符串:tail -n 1 /var/log/nginx/access.log
下面是该命令的输出示例,其中/etc/nginx/html是编译时定义的默认文档根:
/etc/nginx/html 127.0.0.1 - - [15/Mar/2017:17:12:25 +0200] "GET / HTTP/1.1" 404 169 "-" "curl/7.35.0" "-"
如果在Ubuntu上使用apt-get安装,请尝试/usr/share/nginx/www.
编辑:
在最近的版本中,路径已更改为: /usr/share/nginx/html
2019编辑:
你也可以试试/var/www/html/index.nginx-debian.html。
Debian上Nginx的默认目录是/var/www/nginx-default。
可以查看“/etc/nginx/sites-enabled/default”文件
并找到
server {
listen 80 default;
server_name localhost;
access_log /var/log/nginx/localhost.access.log;
location / {
root /var/www/nginx-default;
index index.html index.htm;
}
根节点是默认位置。
在ubuntu 19.04中,我们发现它在
/ usr / html / nginx分享