我对Apache2非常陌生,我试图在服务器上为两个网站提供服务。
我在这里跟踪了文档:https://httpd.apache.org/docs/current/vhosts/examples.html
并试图:
<VirtualHost *:80>
DocumentRoot "var/www/websiteexample1.com"
ServerName www.websiteexample1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "var/www/websiteexample2.com"
ServerName www.websiteexample2.com
</VirtualHost>但是,如果我试图访问www.websiteexample2.com,则会被定向到www.websiteexample1.com的内容。
我遗漏了什么?
发布于 2016-04-18 11:10:32
您的问题可能是您没有在主conf文件中设置关联目录?大致如下:-
#======================================================================
# Note this one is for the secondary root (for www.websiteexample2.com
# This should be changed to whatever you set DocumentRoot to.
<Directory "Your 2nd Website's Directory here">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>您还需要告诉Apache使用/查看虚拟主机文件。因此,如果您没有得到以下内容,请确保它没有被注释掉,并且指向正确的位置:-
# Virtual hosts
Include conf/extra/httpd-vhosts.conf这是基于一个2.2.6版本的Apache
https://stackoverflow.com/questions/36692008
复制相似问题