Html 仅提供欢迎索引页的nginx
我正在EC2服务器上运行nginx 为了解决这个问题,我创建了一个单独的目录usr/loca/nginx/html/test,并将index.html文件的副本放在那里。我从usr/loca/nginx/html中删除了原始index.html文件 这是我的相关代码 nginx.conf.defaultHtml 仅提供欢迎索引页的nginx,html,http,nginx,amazon-ec2,Html,Http,Nginx,Amazon Ec2,我正在EC2服务器上运行nginx 为了解决这个问题,我创建了一个单独的目录usr/loca/nginx/html/test,并将index.html文件的副本放在那里。我从usr/loca/nginx/html中删除了原始index.html文件 这是我的相关代码 nginx.conf.default worker_processes 1; events { worker_connections 1024; } http { include mime.types;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
include usr/local/nginx/conf/*.conf
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html/test;
index index.html index.htm;
}
}
我尝试通过http://‘public ip address’/index.html访问该站点,得到的只是默认的nginx启动页面;即使我删除了这个文件,即使我将原始index.html文件中的文本更改为其他内容
我尝试重新加载nginx并清除缓存等…我认为您的root指令没有指向正确的位置。您的root指令是相对的,即相对于当前文件夹。这是一件非常糟糕的事情。始终执行根相对指令。我会做类似的事情 /home/user/www/localhost 您可以选择一个您喜欢的目录,但要使其与根目录相对。注意前面的斜杠。如果欢迎页面工作正常,那么NGINX工作正常,错误通常在于错误的root指令。您还可以进行以下改进