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

首頁 > 網(wǎng)站 > Apache > 正文

如何配置apache虛擬主機(jī)的實(shí)例小結(jié)

2024-08-27 18:27:50
字體:
供稿:網(wǎng)友

1、基于ip地址的虛擬主機(jī)

代碼如下:
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 和多端口的虛擬主機(jī)配置

代碼如下:
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、單個(gè)IP 地址的服務(wù)器上基于域名的虛擬主機(jī)配置

代碼如下:
# 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>


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

實(shí)驗(yàn)?zāi)繕?biāo):在apache實(shí)現(xiàn)基于域名的虛擬主機(jī)
實(shí)驗(yàn)用的XAMPP版本為1.7.7,內(nèi)含apache版本為2.2.21

實(shí)驗(yàn)前準(zhǔn)備:

1. 為了測(cè)試不同的域名,在Windows/System32/drivers/etc/下覓得hosts文件,在其中添加實(shí)驗(yàn)用的域名若干,如 -

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

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

2. 在apache目錄下建立目錄,以放置您不同的網(wǎng)站。為保護(hù)XAMPP原有的htdocs中的歡迎頁內(nèi)容,實(shí)驗(yàn)另外建立了與htdocs平級(jí)的htdocs1目錄,在其下建立了test1.net, test2.net兩個(gè)子目錄用以放置實(shí)驗(yàn)用的網(wǎng)站。如下 -
apache/htdocs1/test1.net - 放置test1.net網(wǎng)站內(nèi)容
apache/htdocs1/test2.net - 放置test2.net網(wǎng)站內(nèi)容

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 新乡市| 洛南县| 望谟县| 进贤县| 和林格尔县| 鹤山市| 镇远县| 育儿| 门源| 正蓝旗| 阜南县| 武冈市| 宜昌市| 郓城县| 宝应县| 肥乡县| 泾阳县| 嘉鱼县| 屯门区| 甘肃省| 嘉定区| 尉犁县| 张家界市| 奉化市| 祁阳县| 盘锦市| 绵阳市| 青州市| 赫章县| 吉林省| 长宁区| 肃宁县| 新巴尔虎左旗| 青海省| 花莲县| 龙里县| 唐山市| 连平县| 綦江县| 泰安市| 巴青县|