91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

構建虛擬Web主機實例

發布時間:2020-07-19 13:36:43 來源:網絡 閱讀:290 作者:wx5d8a17c45cb5b 欄目:系統運維

構建虛擬Web主機實例

虛擬web主機的定義:

●在同一臺服務器中運行多個Web站點,其中每一個站點并不獨立占用一臺真正的計算機

虛擬主機的優勢:

? 虛擬Web主機指的是在同一臺服務器中運行多個Web站點,其中的每一個站點實際上并不獨自占用整個服務器,因此

被稱為“虛擬Web主機”。 通過虛擬Web主機服務可以充分利用服務器的硬件資源,從而大大降低網站構建及運行成本。

httpd支持的虛擬主機類型:

●基于域名的虛擬主機 (應用最為廣泛)
●基于IP地址的虛擬主機
●基于端口的虛擬主機

特征關系對應分別如下

  • ip相同、端口相同,域名不同;

  • ip不同,端口不同;

  • ip相同,端口不同。
1)基于域名構建示例

構建兩個虛擬web站點

1.www.jj.com

2.www.kk.com

實際流程如下:

使用一臺httpd服務器搭建,ip地址為192.168.68.145.具體構建過程如下:

1.為虛擬主機提供域名解析

安裝bind和httpd服務:yum install -y bind httpd

[root@localhost ~]# vim /etc/named.conf 
[root@localhost ~]# head -21 /etc/named.conf |tail 
options {
        listen-on port 53 { any; };
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        recursing-file  "/var/named/data/named.recursing";
        secroots-file   "/var/named/data/named.secroots";
        allow-query     { any; };

[root@localhost ~]# vim /etc/named.rfc1912.zones 
[root@localhost ~]# vim /etc/named.rfc1912.zones 
[root@localhost ~]# head -34 /etc/named.rfc1912.zones | tail 
zone "ll.com" IN {
        type master;
        file "ll.com.zone";
        allow-update { none; };
};

zone "cc.com" IN {
        type master;
        file "cc.com.zone";
        allow-update { none; };
[root@localhost ~]# cd /var/named/
[root@localhost named]# ls
data  dynamic  named.ca  named.empty  named.localhost  named.loopback  slaves
[root@localhost named]# cp -p named.localhost ll.com.zone
[root@localhost named]# vim ll.com.zone 
[root@localhost named]# cp -p ll.com.zone cc.com.zone
[root@localhost named]# cat ll.com.zone 
$TTL 1D
@       IN SOA  @ rname.invalid. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      @
        A       127.0.0.1
www IN  A       192.168.68.145
[root@localhost named]# cat cc.com.zone 
$TTL 1D
@       IN SOA  @ rname.invalid. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      @
        A       127.0.0.1
www IN  A       192.168.68.145

[root@localhost named]# systemctl start named
[root@localhost named]# systemctl stop firewalld.service 
[root@localhost named]# setenforce 
usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]
[root@localhost named]# setenforce 0
[root@localhost named]# systemctl start httpd

測試是否成功

構建虛擬Web主機實例

[root@localhost named]# cd /etc/httpd/
[root@localhost httpd]# cd conf
[root@localhost conf]# ls
httpd.conf  magic
[root@localhost conf]# mkdir extra
[root@localhost conf]# ls
extra  httpd.conf  magic
[root@localhost conf]# cd extra/
[root@localhost extra]# vim vhost.conf 
[root@localhost extra]# cat vhost.conf 
<VirtualHost *:80>
  DocumentRoot "/var/www/html/ll/"
  ServerName www.ll.com
  ErrorLog "logs/www.ll.com.error_log"
  CustomLog "logs/www.ll.com.access_log" common
  <Directory "/var/www/html/"> 
     Require all granted
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot "/var/www/html/cc/"
  ServerName www.cc.com
  ErrorLog "logs/www.cc.com.error_log"
  CustomLog "logs/www.cc.com.access_log" common
  <Directory "/var/www/html/">
     Require all granted
  </Directory>
</VirtualHost>
[root@localhost extra]# vim /etc/httpd/conf/httpd.conf 
[root@localhost extra]# tail -2 /etc/httpd/conf/httpd.conf 
IncludeOptional conf.d/*.conf
Include conf/extra/vhost.conf

[root@localhost extra]# systemctl restart httpd

構建虛擬Web主機實例

2)基于端口構建示例

根據以上過程可以繼續配置來完成基于端口的構建:

[root@localhost ~]# vim /etc/httpd/conf/extra/vhost.conf 
[root@localhost ~]# tail /etc/httpd/conf/extra/vhost.conf 

<VirtualHost *:8080>
  DocumentRoot "/var/www/html/cc02/"
  ServerName www.cc.com
  ErrorLog "logs/www.cc02.com.error_log"
  CustomLog "logs/www.cc02.com.access_log" common
  <Directory "/var/www/html/">
     Require all granted
  </Directory>
</VirtualHost>
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# mkdir cc02
[root@localhost html]# ls
cc  cc02  ll
[root@localhost html]# cd cc02/
[root@localhost cc02]# vim index.html 
[root@localhost cc02]# cat index.html 
<h2>this is cc02 web</h2>
[root@localhost cc02]# vim /etc/httpd/conf/httpd.conf 
[root@localhost cc02]# head -43 /etc/httpd/conf/httpd.conf | tail -3
Listen 192.168.68.145:80
Listen 192.168.68.145:8080
#Listen 80
[root@localhost cc02]# systemctl restart httpd

測試驗證:輸入http://www.cc02.com:8080/即可

構建虛擬Web主機實例

3)基于IP地址構建示例
[root@localhost cc02]# vim  /etc/httpd/conf/extra/vhost.conf 
[root@localhost cc02]# cat /etc/httpd/conf/extra/vhost.conf 
<VirtualHost 192.168.68.145:80>
  DocumentRoot "/var/www/html/ll/"
  #ServerName www.ll.com
  ErrorLog "logs/www.ll.com.error_log"
  CustomLog "logs/www.ll.com.access_log" common
  <Directory "/var/www/html/"> 
     Require all granted
  </Directory>
</VirtualHost>

<VirtualHost 192.168.68.146:80>
  DocumentRoot "/var/www/html/ll02/"
  #ServerName www.ll.com
  ErrorLog "logs/www.ll02.com.error_log"
  CustomLog "logs/www.ll02.com.access_log" common
  <Directory "/var/www/html/"> 
     Require all granted
  </Directory>
</VirtualHost>
#<VirtualHost *:80>
#  DocumentRoot "/var/www/html/cc/"
#  ServerName www.cc.com
#  ErrorLog "logs/www.cc.com.error_log"
#  CustomLog "logs/www.cc.com.access_log" common
#  <Directory "/var/www/html/">
#     Require all granted
#  </Directory>
#</VirtualHost>
#
#<VirtualHost *:8080>
#  DocumentRoot "/var/www/html/cc02/"
#  ServerName www.cc.com
#  ErrorLog "logs/www.cc02.com.error_log"
#  CustomLog "logs/www.cc02.com.access_log" common
#  <Directory "/var/www/html/">
#     Require all granted
#  </Directory>
#</VirtualHost>
[root@localhost cc02]# mkdir ll02
[root@localhost cc02]# cd ll02
[root@localhost ll02]# vim index.html
[root@localhost ll02]# cat index.html 
<h2>this is ll02 146</h2>
[root@localhost ll02]# vim /etc/httpd/conf/httpd.conf 
[root@localhost ll02]# head -43 /etc/httpd/conf/httpd.conf  | tail -5
# prevent Apache from glomming onto all bound IP addresses.
#
Listen 192.168.68.145:80
Listen 192.168.68.146:80
#Listen 192.168.68.145:8080

測試驗證:輸入192.168.68.146

構建虛擬Web主機實例

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

伊吾县| 英超| 凉山| 醴陵市| 桑植县| 东兰县| 定日县| 蒲城县| 双流县| 平遥县| 公主岭市| 思南县| 信丰县| 会理县| 基隆市| 手游| 保靖县| 大连市| 澄城县| 娄底市| 扎囊县| 凤城市| 固始县| 北流市| 拉孜县| 朝阳区| 乌兰察布市| 麻城市| 舟曲县| 九台市| 西平县| 铜鼓县| 平远县| 瑞丽市| 南江县| 临泉县| 西青区| 临夏县| 巴马| 永登县| 宝应县|