Apache httpd.conf配置问题
我目前正在将一些网站迁移到AmazonLinuxAMI上运行的AmazonEC2上,并且很难让Apache的VirtualHost配置正常工作 下面是我的httpd.conf文件的样子:Apache httpd.conf配置问题,apache,amazon-ec2,virtualhost,Apache,Amazon Ec2,Virtualhost,我目前正在将一些网站迁移到AmazonLinuxAMI上运行的AmazonEC2上,并且很难让Apache的VirtualHost配置正常工作 下面是我的httpd.conf文件的样子: <VirtualHost *:80> ServerName example.com DocumentRoot /home/sites/example.com/ <Directory /home/sites/example.com> Opt
<VirtualHost *:80>
ServerName example.com
DocumentRoot /home/sites/example.com/
<Directory /home/sites/example.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/example.com.error.log
LogLevel warn
CustomLog /var/log/httpd/example.com.access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName blog.example.com
DocumentRoot /home/sites/blog.example.com/
<Directory /home/sites/blog.example.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/blog.example.com.error.log
LogLevel warn
CustomLog /var/log/httpd/blog.example.com.access.log combined
</VirtualHost>
但是,如果我尝试访问blog.example.com,我会得到一个ERR_NAME_NOT_RESOLVED响应
如果我将第一个VirtualHost定义更改为blog.example.com,我可以加载blog.example.com站点,因此这两个站点都正常工作,这让我怀疑我在VirtualHost中配置了错误,或者在我的域注册器的末尾配置了错误。我的问题是我在blog.example.com域之前拥有example.com域,意思是所有的东西都去了example.com。秩序很重要 您的问题可能是DNS。你有blog.example.com的记录吗?所以我应该有一个example.com和blog.example.com的记录,它们都指向同一个IP,对吗?这对我来说仍然不起作用。啊,这只是一个顺序问题,该网站的域名前缀版本需要放在example.com之前。
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443 example.com (/etc/httpd/conf.d/ssl.conf:74)
*:80 is a NameVirtualHost
default server example.com (/etc/httpd/conf/httpd.conf:1012)
port 80 namevhost example.com (/etc/httpd/conf/httpd.conf:1012)
port 80 namevhost blog.example.com (/etc/httpd/conf/httpd.conf:1029)
Syntax OK