2011-03-05 17 views

回答

2

由於@Pekka寫道,你確實找VirtualHost指令,但我以爲我想補充一個例子配置您的虛擬主機配置。這應該被放置在你的httpd.conf文件,編輯您的喜好,記得填寫完整路徑:

NameVirtualHost v1.yoursite.com:80 
<VirtualHost v1.yoursite.com:80> 
    ServerName v1.yoursite.com 
    ServerAlias v1.yoursite.com 
    DocumentRoot /path/to/site_v1 
    ErrorLog /path/to/prefered/error.log 
    CustomLog /path/to/prefered/access.log combined 
    <Directory /path/to/site_v1> 
     Options Indexes FollowSymLinks MultiViews 
     AllowOverride None 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

NameVirtualHost v2.yoursite.com:80 
<VirtualHost v2.yoursite.com:80> 
    ServerName v2.yoursite.com 
    ServerAlias v2.yoursite.com 
    DocumentRoot /path/to/site_v2 
    ErrorLog /path/to/prefered/error.log 
    CustomLog /path/to/prefered/access.log combined 
    <Directory /path/to/site_v2> 
     Options Indexes FollowSymLinks MultiViews 
     AllowOverride None 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

如果你願意,你可以選擇使用不同的接入/錯誤日誌中的每個版本的現場。只需更改日誌文件的名稱/路徑,即可完成。 /path/to是網站文件夾的路徑,v1.yoursite.com & v2.yoursite.com應該更改爲您想要用於每個版本的相關域。如果您不想更改日誌文件,請刪除ErrorLogCustomLog指令,我將默認設置爲httpd.conf中設置的主日誌文件