Apache2:Index.html加载IP,但不加载域名(Ubuntu)



我制作了一个AWS EC2实例并获得了一个弹性IP。
Elastic IP用于将域名(从GoDaddy购买)设置为AWS EC2实例。
EC2实例正在运行Apache2服务器。

根据手册,我应该用我自己的index.html替换/var/www/html/中的index.html,我做到了。

当我使用Elastic IP时,会显示我设置的index.html页面。
然而,当我使用域名时,由于某种原因,它会给我默认的apache2页面,尽管该文件在被覆盖后已不存在。我可以用DomainName.in/index.html访问index.html。

简单地说:
-DomainName.in为apache2提供了不应该存在的默认index.html
-DomainName.in/index.html提供了我要显示的页面
-ElasticIP和ElasticIP/index.html都给出了我想要显示的页面

我如何才能让我在浏览器中输入域名就可以进入我想要的index.html页面?

您需要在位于此处的虚拟主机配置中设置DirectoryIndex:/etc/apache2/apache2.conf

如果你的配置文件不在那里,你可以通过运行:/usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE 找到它

<virtualhost *:80>
  ServerName  domain.com
  ServerAlias www.domain.com
  # Index file and Document Root (where the public files are located)
  DirectoryIndex home.html index.html
  DocumentRoot /var/www
</virtualhost>

好的,所以一切都很好,但由于某些原因,更改需要时间才能通过DNS传播。
大约半小时后,情况发生了变化。

最新更新