国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Apache > 正文

如何配置apache虛擬主機的實例小結

2024-08-27 18:23:26
字體:
來源:轉載
供稿:網友
如果你是第一次配置apache虛擬主機,那么通過閱讀這篇文章你將會了解到如何實現apache虛擬主機配置。其實要配置好一臺虛擬主機沒有想象中那么難

1、基于ip地址的虛擬主機

復制代碼 代碼如下:
Listen 80
<VirtualHost 172.20.30.40>
    DocumentRoot /home/httpd/html1
    ServerName www.ok1.com
    ErrorLog /usr/local/apache/logs/error1_log
    CustomLog /usr/local/apache/logs/access1_log combined
</VirtualHost>
<VirtualHost 172.20.30.50>
    DocumentRoot /home/httpd/html2
    ServerName www.ok2.com
    ErrorLog /usr/local/apache/logs/error2_log
    CustomLog /usr/local/apache/logs/access2_log combined
</VirtualHost>

 2、基于IP 和多端口的虛擬主機配置

復制代碼 代碼如下:
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080

<VirtualHost 172.20.30.40:80>
 DocumentRoot /www/example1-80
 ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.40:8080>

 DocumentRoot /www/example1-8080
 ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.50:80>
 DocumentRoot /www/example2-80
 ServerName www.example1.org
</VirtualHost>
<VirtualHost 172.20.30.50:8080>
 DocumentRoot /www/example2-8080
 ServerName www.example2.org
</VirtualHost>

3、單個IP 地址的服務器上基于域名的虛擬主機配置

復制代碼 代碼如下:
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.com
ServerAlias example1.com. *.example1.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here
</VirtualHost>


如果您感覺上面的文章還不夠詳細可以看下下面的文章:

實驗目標:在apache實現基于域名的虛擬主機
實驗用的XAMPP版本為1.7.7,內含apache版本為2.2.21

實驗前準備:

1. 為了測試不同的域名,在Windows/System32/drivers/etc/下覓得hosts文件,在其中添加實驗用的域名若干,如 -

復制代碼 代碼如下:
127.0.0.1   test1.net
127.0.0.1   test2.net

如此,則在瀏覽器中輸入該倆域名時,Windows將其解析為127.0.0.1本地地址。即,在瀏覽器中訪問localhost, test1.net, test2.net均可訪問XAMPP的歡迎頁。

2. 在apache目錄下建立目錄,以放置您不同的網站。為保護XAMPP原有的htdocs中的歡迎頁內容,實驗另外建立了與htdocs平級的htdocs1目錄,在其下建立了test1.net, test2.net兩個子目錄用以放置實驗用的網站。如下 -
apache/htdocs1/test1.net - 放置test1.net網站內容
apache/htdocs1/test2.net - 放置test2.net網站內容

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 吉木乃县| 嘉祥县| 江陵县| 阿克苏市| 汾西县| 遂宁市| 财经| 奈曼旗| 陆河县| 拉萨市| 体育| 扎赉特旗| 珲春市| 伊春市| 山东省| 章丘市| 伊吾县| 黄石市| 搜索| 汪清县| 怀仁县| 和龙市| 长宁县| 紫阳县| 达孜县| 榆中县| 南部县| 铜川市| 兴山县| 南华县| 太白县| 古丈县| 泸州市| 南昌县| 长乐市| 综艺| 玉山县| 边坝县| 鄂托克前旗| 庆元县| 罗甸县|