简体   繁体   English

VirtualHost不起作用

[英]VirtualHost doesn't work

I have a very simple configuration but I only receive a "page not avaiable" as response. 我的配置非常简单,但仅收到“页面不可用”作为响应。

Currently I'm running an Amazon EC2 instance with EBS and RDD and using Route53 as the DNS system. 目前,我正在使用EBS和RDD运行Amazon EC2实例,并使用Route53作为DNS系统。 The DNS are correctly working and pointing to the EC2 machine (checked with a nslookup) DNS正常工作并指向EC2计算机(已通过nslookup检查)

In the EC2 machine I created my site in the folder: 在EC2机器中,我在以下文件夹中创建了我的站点:

/var/www/html/pazzanicastanhas.com.br

and in the file /etc/httpd/conf.d/httpd-vhosts.conf I have only the following 在文件/etc/httpd/conf.d/httpd-vhosts.conf中,我只有以下内容

NameVirtualHost *:80
<VirtualHost *:80>
  DocumentRoot /var/www/html/pazzanicastanhas.com.br
  ServerName www.pazzanicastanhas.com.br
</VirtualHost>

When I try to access the site through the domain www.pazzanicastanhas.com.br I just get a error saying the page doesn't exist, if I use the default public DNS or the direct IP of the machine provided by amazon, everything works. 当我尝试通过域名www.pazzanicastanhas.com.br访问该网站时,如果我使用默认的公共DNS或亚马逊提供的机器的直接IP,则会收到错误消息,指出该页面不存在,一切正常。 The thing is the virtualhost doesn't understand to point the domain to the correct folder in the machine. 问题是虚拟主机无法将域指向机器中的正确文件夹。

Any ideas on what I might be doing wrong? 关于我可能做错了什么的任何想法?

PS.: The file /etc/httpd/conf.d/httpd-vhosts.conf is being included because if I insert the following line PS .:包含文件/etc/httpd/conf.d/httpd-vhosts.conf,因为如果我插入以下行

Alias /pazzanicastanhas /var/www/html/pazzanicastanhas.com.br 

it works just fine by accessing it with the Public DNS provided by amazon with a /pazzanicastanhas at the end, which in this case would be 通过使用由亚马逊提供的公共DNS(末尾带有/ pazzanicastanhas)访问它,可以很好地工作,在这种情况下,

http://ec2-54-207-88-168.sa-east-1.compute.amazonaws.com/pazzanicastanhas http://ec2-54-207-88-168.sa-east-1.compute.amazonaws.com/pazzanicastanhas

One thing I notice is that there is no DNS record for www.pazzanicastanhas.com.br , but there is for pazzanicastanhas.com.br : 有一两件事我注意到的是,不存在用于DNS记录www.pazzanicastanhas.com.br ,但对于pazzanicastanhas.com.br

$ dig +short www.pazzanicastanhas.com.br
$ dig +short pazzanicastanhas.com.br
54.207.88.168

And when you try to load pazzanicastanhas.com.br there is a 301 redirect to the www site: 而当您尝试加载pazzanicastanhas.com.br时,将有301重定向到www网站:

$ curl -v -s pazzanicastanhas.com.br
[snip]
< HTTP/1.1 301 Moved Permanently
< Server: Apache/2.2.26 (Amazon)
< X-Powered-By: PHP/5.3.28
< X-Pingback: http://www.pazzanicastanhas.com.br/xmlrpc.php
< Location: http://www.pazzanicastanhas.com.br/

But since www doesn't actually exist this will never work. 但是由于www实际上并不存在,因此它将永远无法工作。

So it looks like you need to create an A record for www.pazzanicastanhas.com.br that points to your EC2 instance. 因此,您似乎需要为www.pazzanicastanhas.com.br创建一个指向您的EC2实例的A记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM