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

首頁 > 網站 > Apache > 正文

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

2024-08-27 18:24:45
字體:
來源:轉載
供稿:網友

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網站內容

 在這兩個目錄中各新建hello world一網頁 index.html,內容 -

復制代碼 代碼如下:
<HTML>
<HEAD></HEAD>
<BODY>
<H1>hello~, 這是[對應的網站名,用以區(qū)別].net</H1></BODY>

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 酒泉市| 临桂县| 东明县| 靖安县| 金川县| 衡阳县| 将乐县| 辽宁省| 大冶市| 郎溪县| 民丰县| 五寨县| 赤峰市| 洪泽县| 原阳县| 柯坪县| 增城市| 松江区| 西盟| 巫山县| 平顶山市| 郎溪县| 红河县| 靖江市| 齐河县| 门头沟区| 锦屏县| 黄骅市| 定远县| 东莞市| 丘北县| 海淀区| 海安县| 金华市| 中超| 文成县| 太仓市| 纳雍县| 大姚县| 临泽县| 德昌县|