我正在尝试向我的apache配置中添加第二个虚拟主机,但是似乎无法使用新的虚拟主机。
我httpd.conf
只包含以下行:
ServerName radiofreebrighton.org.uk
我还有一个ports.conf
文件,其中包含以下内容:
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
Listen 443
</IfModule>
我有两个文件,sites-available
这是符号链接到sites-enabled
由a2ensite
:
- radiofreebrighton.org.uk
- trafalgararches.co.uk
第一个的内容是:
<VirtualHost _default_:80>
DocumentRoot /home/tom/www
ServerAdmin tom@radiofreebrighton.org.uk
ServerName radiofreebrighton.org.uk
ServerAlias www.radiofreebrighton.org.uk
<Directory /home/tom/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel error
CustomLog /var/log/apache2/access.log combined
Alias /wiki /home/tom/www/mediawiki/index.php
</VirtualHost>
后者的内容是:
<VirtualHost *:80>
DocumentRoot /home/tom/tata-www
ServerAdmin admin@trafalgararches.co.uk
ServerName trafalgararches.co.uk
ServerAlias www.trafalgararches.co.uk
<Directory /home/tom/tata-www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
logLevel error
ErrorLog /var/log/apache2/error.log
</VirtualHost>
但是,只要我从trafalgararches.co.uk请求页面,就会从radiofreebrighton.org.uk获得页面。为什么会这样呢?我该如何解决?
编辑:
apache理解的虚拟主机配置:
tom@rfb:/usr/local$ apache2ctl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server radiofreebrighton.org.uk (/etc/apache2/sites-enabled/radiofreebrighton.org.uk:1)
port 80 namevhost radiofreebrighton.org.uk (/etc/apache2/sites-enabled/radiofreebrighton.org.uk:1)
port 80 namevhost trafalgararches.co.uk (/etc/apache2/sites-enabled/trafalgararches.co.uk:1)
Syntax OK
(通过apache2ctl -S
aka 收集httpd -S
。)
NameVirtualHost *:80
您的配置中是否有某处?
ServerName
和ServerAlias
行尾的斜杠。另外,请确保您已重新启动apache。