婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > linux7下虛擬主機的三種實現方式

linux7下虛擬主機的三種實現方式

熱門標簽:新科美甲店地圖標注 蘭州ai電銷機器人招商 外呼系統打哪顯哪 江西外呼系統 湖北ai智能電銷機器人 高德地圖標注論壇 AI電銷機器人 源碼 新邵電銷機器人企業(yè) 北海市地圖標注app

一、 相同IP地址,不同端口號

虛擬主機1:主機IP地址為172.16.30.20,端口號為80(默認端口),DocumentRoot是/var/www/vhost1,在DocumentRoot目錄下創(chuàng)建虛擬主機站點主頁文件。

[root@rhel7 ~]# cd /var/www/
[root@rhel7 www]# mkdir vhost1
[root@rhel7 www]# cd vhost1/
[root@rhel7 vhost1]# vim index.html
[root@rhel7 vhost1]# cat index.html
this is the vhost1

虛擬主機2:主機IP地址為172.16.30.20,端口號為8080,DocumentRoot是/var/www/vhost2,在DocumentRoot目錄下創(chuàng)建虛擬主機站點主頁文件。

[root@rhel7 ~]# cd /var/www/
[root@rhel7 www]# mkdir vhost2
[root@rhel7 www]# cd vhost2/
[root@rhel7 vhost2]# vim index.html
[root@rhel7 vhost2]#
[root@rhel7 vhost2]# cat index.html
this is the vhost2

編輯虛擬機主機配置文件httpd-vhosts.conf

[root@rhel7 ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf
<VirtualHost 172.16.30.10:80>
  DocumentRoot "/var/www/vhost1"
</VirtualHost>
Listen 8080
<VirtualHost 172.16.30.10:8080>
  DocumentRoot "/var/www/vhost2"
</VirtualHost>
[root@rhel7 ~]# systemctl restart httpd
[root@rhel7 ~]# firewall-cmd --add-port=8080/tcp --permanent
success
[root@rhel7 ~]# firewall-cmd --reload
success

訪問測試:


二、 不同IP地址,相同端口號

虛擬主機1:主機IP地址為172.16.30.20,端口號為80(默認端口),DocumentRoot是/var/www/vhost1,在DocumentRoot目錄下創(chuàng)建虛擬主機站點主頁文件。

虛擬主機2:主機IP地址為172.16.30.200,端口號為80(默認端口),DocumentRoot是/var/www/vhost2,在DocumentRoot目錄下創(chuàng)建虛擬主機站點主頁文件。

[root@rhel7 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=bde41fa3-f559-4de2-ba9a-857fed211aac
DEVICE=ens33
ONBOOT=yes
DNS1=127.0.0.1
ZONE=public
IPADDR=172.16.30.10
PREFIX=24
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPADDR1=172.16.30.100
PREFIX1=24
[root@rhel7 ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf
<VirtualHost 172.16.30.10:80>
  DocumentRoot "/var/www/vhost1"
</VirtualHost>

<VirtualHost 172.16.30.100:80>
  DocumentRoot "/var/www/vhost2"
</VirtualHost>

[root@rhel7 ~]# systemctl restart httpd

訪問測試:



三、 相同IP地址,相同端口號,不同FQDN

虛擬主機1:主機IP地址為172.16.30.20,端口號為80(默認端口),FQDN為vhost1.example.com,DocumentRoot是/var/www/vhost1,在DocumentRoot目錄下創(chuàng)建虛擬主機站點主頁文件。

虛擬主機2:主機IP地址為172.16.30.20,端口號為80(默認端口),FQDN為vhost2.example.com,DocumentRoot/var/www/vhost2,在DocumentRoot目錄下創(chuàng)建虛擬主機站點主頁文件。

[root@rhel7 ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf
<VirtualHost 172.16.30.10:80>
  DocumentRoot "/var/www/vhost1"
  ServerName vhost1.example.com
</VirtualHost>
<VirtualHost 172.16.30.10:80>
  DocumentRoot "/var/www/vhost2"
  ServerName vhost2.example.com
</VirtualHost>

注意:DNS服務器中需要添加對應的解析內容。


訪問測試:


記得每次修改完配置文件后需要重啟服務。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

標簽:池州 黃石 自貢 阿克蘇 海南 黔東 南陽 大理

巨人網絡通訊聲明:本文標題《linux7下虛擬主機的三種實現方式》,本文關鍵詞  linux7,下,虛擬主機,的,三種,;如發(fā)現本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《linux7下虛擬主機的三種實現方式》相關的同類信息!
  • 本頁收集關于linux7下虛擬主機的三種實現方式的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 临海市| 德惠市| 贺兰县| 方城县| 鄂州市| 宁城县| 晋宁县| 射阳县| 遵化市| 天峨县| 达尔| 资兴市| 天津市| 嵊州市| 稷山县| 离岛区| 永清县| 大化| 都江堰市| 炉霍县| 吉安县| 册亨县| 禄丰县| 汝州市| 聂拉木县| 定陶县| 大连市| 镇远县| 白玉县| 阆中市| 天津市| 泰和县| 库车县| 襄垣县| 潞城市| 天等县| 汉寿县| 海盐县| 吉林市| 北海市| 洛川县|