我想在一个EC2实例上设置多个网站托管。两个域指向一个IP地址 我将/etc/httpd/conf/httpd.conf文件配置为 -
#NameVirtualHost *
<VirtualHost *>
DocumentRoot "/var/www/html"
ServerName domain1.com
ServerAlias www.domain1.com
<Directory "/var/www/html">
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot "/var/www/domain2"
ServerName domain2.com
ServerAlias www.domain2.com
<Directory "/var/www/domain2">
AllowOverride All
Require all Granted
</Directory>
# RewriteEngine On
</VirtualHost>
问题是服务器仅指向domain1.com 当我将domain2.com放入URL时,它会向我显示apache默认页面“Amazon Linux AMI Test Page”
我之所以评论NameVirtualHost *是在重启httpd服务之后,我得到了
启动httpd:AH00548:NameVirtualHost无效,将在下一版本中删除/etc/httpd/conf/httpd.conf:355
我还应该做什么设置?请帮帮我。
由于
答案 0 :(得分:2)
经过大量的试验和错误;最后它工作.. :)
我改为httpd.conf文件中的以下代码 -
<VirtualHost *:80>
ServerName alivefruits.com
ServerAlias www.alivefruits.com
DocumentRoot "/var/www/html"
</VirtualHost>
<VirtualHost *:80>
ServerName revealautomation.com
ServerAlias www.revealautomation.com
DocumentRoot "/var/www/html/reveal"
<Directory "/var/www/html/reveal">
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
答案 1 :(得分:0)
您的虚拟主机配置缺少端口。而不是
<VirtualHost *>
试
<VirtualHost *:80>