1 配置基于IP地址的虛擬主機(jī)1.1 單" />

国产成人精品无码青草_亚洲国产美女精品久久久久∴_欧美人与鲁交大毛片免费_国产果冻豆传媒麻婆精东

15158846557 在線咨詢 在線咨詢
15158846557 在線咨詢
所在位置: 首頁 > 營銷資訊 > 網(wǎng)站運(yùn)營 > Apache 配置虛擬主機(jī)

Apache 配置虛擬主機(jī)

時間:2023-07-17 12:21:01 | 來源:網(wǎng)站運(yùn)營

時間:2023-07-17 12:21:01 來源:網(wǎng)站運(yùn)營

Apache 配置虛擬主機(jī): 虛擬主機(jī)是在一臺Web服務(wù)器上,可以為多個獨(dú)立的IP地址、域名或端口號提供不同的Web站點(diǎn)。對于訪問量不大的站點(diǎn)來說,這樣可以降低單個站點(diǎn)的運(yùn)營成本。

1 配置基于IP地址的虛擬主機(jī)

1.1 單網(wǎng)卡配置雙IP

單網(wǎng)卡配置雙IP

1.2 分別創(chuàng)建兩個主目錄和默認(rèn)文件

mkdir /var/www/ip1 /var/www/ip2echo "this is 192.168.184.128's web"> /var/www/ip1/index.htmlecho "this is 192.168.184.129's web"> /var/www/ip2/index.html

1.3 添加/etc/httpd/conf.d/vhost.conf

<Virtualhost 192.168.184.128> DocumentRoot /var/www/ip1</Virtualhost><Virtualhost 192.168.184.129> DocumentRoot /var/www/ip2</Virtualhost>

1.4 重啟服務(wù)

systemctl restart httpd

1.5 關(guān)閉SELinux,防火墻放行httpd

setenforce 0firewall-cmd --add-service=http --permanentfirewall-cmd --reload

2 配置基于域名的虛擬主機(jī)

2.1 分別創(chuàng)建兩個主目錄和默認(rèn)文件

mkdir /var/www/www1 /var/www/www2echo "www1.test123.com's web."> /var/www/www1/index.htmlecho "www2.test123.com's web."> /var/www/www2/index.html

2.2 修改/etc/httpd/conf.d/vhost.conf文件

<Virtualhost 192.168.184.128> DocumentRoot /var/www/www1 ServerName www1.test123.com</Virtualhost><Virtualhost 192.168.184.128> DocumentRoot /var/www/www2 ServerName www2.test123.com</Virtualhost>

2.3 重啟服務(wù)

systemctl restart httpd

2.4 配置測試主機(jī)hosts文件

Linux 操作系統(tǒng):編輯/etc/hosts,在配置文件后面添加一下內(nèi)容

192.168.184.128 www1.test123.com192.168.184.128 www2.test123.comWindows操作系統(tǒng): 編輯C:/Windows/System32/drivers/etc/hosts,在配置文件后面添加一下內(nèi)容

192.168.184.128 www1.test123.com192.168.184.128 www2.test123.com

3 基于端口號的虛擬主機(jī)的配置

3.1 分別創(chuàng)建兩個主目錄和默認(rèn)文件

mkdir /var/www/8088 /var/www/8089echo "8088 port's web."> /var/www/8088/index.htmlecho "8089 port's web."> /var/www/8089/index.html

3.2 修改/etc/httpd/conf.d/vhost.conf文件

Listen 8088Listen 8089<Virtualhost 192.168.184.128:8088> DocumentRoot /var/www/8088</Virtualhost><Virtualhost 192.168.184.128:8089> DocumentRoot /var/www/8089</Virtualhost>

3.3 重啟服務(wù)

systemctl restart httpd

3.4 防火墻放通8088、8089端口

firewall-cmd --add-port=8088-8089/tcp --permanentfirewall-cmd --reload











關(guān)鍵詞:主機(jī),虛擬,配置

74
73
25
news

版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。

為了最佳展示效果,本站不支持IE9及以下版本的瀏覽器,建議您使用谷歌Chrome瀏覽器。 點(diǎn)擊下載Chrome瀏覽器
關(guān)閉