2009-05-25 144 views
1

一些細節問題與配置虛擬主機

  • XAMPP 1.7.1
  • 操作系統Vista上的測試和XP

大家好。我在配置我的虛擬主機時遇到了一些問題。 目前我有兩個網站。

這裏是我的vhost.conf文件:

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot c:/xampp/htdocs/site1/trunk/ 
    ServerName site1.local 
</VirtualHost> 

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot c:/xampp/htdocs/site2/trunk/ 
    ServerName site2.local 
</VirtualHost> 

當然,在我的主機文件和我有

127.0.0.1 site1.local 
127.0.0.1 site2.local 

我已經重新啓動Apache的,以及我的瀏覽器不同的時間。

這裏是我的問題:

http://site1.local作品。但是當我去http://site2.local,我登陸site1.local。

任何想法的?

+1

這是vhost.conf和httpd.conf中同一個? – Eugene 2010-08-16 20:45:22

回答

2

嘗試

<VirtualHost "site1.local"> 
    ServerAdmin [email protected]##ad#.nl 
    DocumentRoot c:/xampp/htdocs/site1/trunk/ 
    ServerName site1.local 
</VirtualHost> 

<VirtualHost "site2.local"> 
    ServerAdmin [email protected]##ad#.nl 
    DocumentRoot c:/xampp/htdocs/site2/trunk/ 
    ServerName site2.local 
</VirtualHost> 

你總是得到site1的因爲Apache默認爲第一。

編輯

取消註釋

#NameVirtualHost * 

NameVirtualHost * 

在httpd.conf

礦說(/etc/httpd/conf/httpd.conf中)

126 # Listen: Allows you to bind Apache to specific IP addresses and/or 
127 # ports, in addition to the default. See also the <VirtualHost> 
128 # directive. 
129 # 
130 # Change this to Listen on specific IP addresses as shown below to 
131 # prevent Apache from glomming onto all bound IP addresses (0.0.0.0) 
132 # 
133 Listen 127.0.0.1:80 
134 NameVirtualHost 127.0.0.1 

我的虛擬主機文件有

<VirtualHost "www.whatever.com"> 
     DocumentRoot /var/www/html/whatever/pub 
     ErrorLog logs/error_log 
     ServerName www.whatever.com 
... 
+0

我試過,沒有引號但沒有結果 – sanders 2009-05-25 14:58:26