統環境:vmware虛擬機 debian4.0
系統Ip爲192.168.1.121
原文地址:http://blog.chinaunix.net/u2/73230/showart_1432737.html
當安裝好apache2,其主目錄爲/var/www/,不過如何來設置第2個等主機呢。
本文介紹了在deiban下如何來進行設置虛擬主機。
1.在/var/www/下創建一個test目錄
# mkdir /var/www/test
# nano /etc/apache2/sites-available/test
<VirtualHost 192.168.1.121> ServerName lixq.example.com ServerAdmin [email protected] DocumentRoot /var/www/test/ ErrorLog /var/log/apache2/test_erro.log CustomLog /var/log/apache2/test_access.log combined </VirtualHost> |
使/etc/apache2/sites-enabled/目錄中多了一個/etc/apache2/sites-available/test 的軟鏈接。
4.重啓apache2
# /etc/init.d/apache2 restart
由於配置是在虛擬機上的debian系統上配置的,所以需要在你的Windows系統目錄C:\WINDOWS\system32\drivers\etc 下修改hosts文件,添加如下一句。
192.168.1.121 lixq.example.com |
然後在IE瀏覽器上,訪問lixq.example.com 就可以訪問到你放在/var/www/test目錄下的站點啦。
-------------------------
重定向
<VirtualHost *>
ServerName www.abc.org
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
RewriteENgine On
#RewriteBase /
RewriteRule ^(.*)$ http://www.abc.org:8888/
</Directory>
</VirtualHost>