2012-05-01 220 views
0

好的。我的本地開發機器上有LAMP服務器。我需要開發幾個網站。所以,我已經在$ APACHE/sites-available中創建了兩個文件(我的站點的配置),併爲他們啓用了/ sites-enabled的符號鏈接。之後,我開始sudo /etc/init.d/apache2 restart。沒有錯誤或警告。當我嘗試mysite.dev時,它會給出它,當foobar.dev - 它給出mysite.dev!Apache Multiply Sites again

所以,Apache爲所有虛擬主機提供了一個站點。如何解決它?

http://pastebin.com/qjcx6RS3(第一現場) http://pastebin.com/FdVStJm8(第二站點)

回答

0

你需要設置NameVirtualHost-directive這樣在httpd.conf:

NameVirtualHost *:80 

例子有兩個虛擬主機(像你的情況):當然

NameVirtualHost *:80 

<VirtualHost *:80> 
ServerName www.domain.tld 
ServerAlias domain.tld *.domain.tld 
DocumentRoot /www/domain 
</VirtualHost> 

<VirtualHost *:80> 
ServerName www.otherdomain.tld 
DocumentRoot /www/otherdomain 
</VirtualHost> 

...這將也有可能include的虛擬主機來回回m分隔文件到httpd.conf中。

+0

現在它打印:「NameVirtualHost *:80沒有虛擬主機」 – tucnak

+0

請確保包含您的虛擬主機文件(http://httpd.apache.org/docs/2.0/de/mod/core.html#include )在httpd.conf中移動'ServerName',並在severfault中提到'' – Seybsen

+0

之內提到它也可以在你的配置中設置兩次'NameVirtualHost':http://serverfault.com/問題/ 1405 /阿帕奇-2-啓動預警-了NameVirtualHost-80-HAS-無virtualhosts – Seybsen