2011-01-07 119 views
1

我已經安裝WAMP的服務器,它工作正常 然後我嘗試虛擬主機有了它,它不工作虛擬主機上沒有WAMP服務器工作

在httpd.conf文件中我添加這些行

Listen 8081 
Listen 8082 
Include conf/extra/httpd-vhosts.conf 

而在的httpd-vhosts.conf

NameVirtualHost *:80 
Listen 8081 
Listen 8082 

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host.localhost" 
    ServerName dummy-host.localhost 
    ServerAlias www.dummy-host.localhost 
    ErrorLog "logs/dummy-host.localhost-error.log" 
    CustomLog "logs/dummy-host.localhost-access.log" common 
</VirtualHost> 

<VirtualHost localhost:8081> 
    ServerName localhost:8081 
    DocumentRoot "D:/wamp/www/project/" 
    Alias /index.html D:/wamp/www/project/index.php 
</VirtualHost> 

<VirtualHost localhost:8082> 
    ServerName localhost:8082 
    DocumentRoot "D:/wamp/www/project1/" 
    Alias /index.html D:/wamp/www/project1/index.php 
</VirtualHost> 
+0

您只能從運行服務器的本地計算機上嘗試?因爲`localhost`與`127.0.0.1`(IPv4)和`:: 1`(IPv6);-)靜態關聯。所以如果你試圖從另一臺機器訪問它,你會遇到麻煩。 – thedom 2011-01-07 12:48:08

回答

2

我不明白爲什麼你試圖指向DIFF端口DIFF項目...

你可以寫的httpd-vhosts.conf這樣的事情:

<VirtualHost 127.0.0.1> 
    DocumentRoot "D:/wamp/www/project/" 
    # ServerName project[1 ... n].local or domain.name.com 
    ServerName project1.local 
</VirtualHost> 

,那麼你必須編輯您的主機從C文件:\ WINDOWS \ SYSTEM32 \ drivers \ etc下,以你的IP匹配您的地域

重啓Apache,這一切

有效的URL應該是這樣的:http://project1.local - 在那裏你會的hve的PROJECT1 forlder; 爲了有多個項目,你可以設置許多VistualHosts指令,你需要 歡呼,

3

我看到這是一個有點老問題,但仍然我的WAMP不支持啓用vhost。 主機:

<code> 
127.0.0.1 localhost 
127.0.0.1 sweetdreams.localhost 
127.0.0.1 sweetdreams.com 
</code> 

的httpd.conf:

LoadModule vhost_alias_module modules/mod_vhost_alias.so 
LoadModule php5_module "D:/wamp/bin/php/php5.3.4/php5apache2_2.dll" 
# Virtual hosts 
Include conf/extra/httpd-vhosts.conf 


Include "D:/wamp/alias/*" 

VirtualDocumentRoot "D:/wamp/www/%0" 

htppd-vhosts.conf:

NameVirtualHost 127.0.0.1:80 

<VirtualHost 127.0.0.1:80> 
    ServerName localhost 
    DocumentRoot "d:/wamp/www"      #this is default wamp root for websites, 
</VirtualHost> 

<VirtualHost 127.0.0.1:80> 
    ServerName www.sweetdreams.com 
    ServerAlias www.sweetdreams.com sweetdreams.com    #your virtual domain name 
    DocumentRoot "d:/wamp/www/sweetdreams"      #location of your site, no extenison needed. 

<Directory "d:/wamp/www/sweetdreams">        #again location of your website 
    Order Allow,Deny 
    Allow from all 
</Directory> 
</VirtualHost> 

我WAMP的圖標還是處於橙色時,啓用虛擬主機模塊,並添加虛擬主機的conf。

1

我正在運行到相同的問題,當我在兩個位置的端口服務器將無法運行。它會留在奧蘭治。嘗試刪除NameVirtualHost中的端口,使其看起來像這樣:

NameVirtualHost 127.0.0.1 

<VirtualHost 127.0.0.1:80> 
ServerName localhost 
DocumentRoot "d:/wamp/www"   
</VirtualHost> 

<VirtualHost 127.0.0.1:80> 
ServerName www.sweetdreams.com 
ServerAlias www.sweetdreams.com *.sweetdreams.com  
DocumentRoot "d:/wamp/www/sweetdreams" 
</VirtualHost>