In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
To build a virtual Web host instance, define a virtual web host:
● runs multiple Web sites on the same server, each of which does not independently occupy a real computer
Advantages of virtual hosting:
A virtual Web host refers to running multiple Web sites on the same server, each of which does not actually occupy the entire server, so
It is called "virtual Web host". Through the virtual Web host service, we can make full use of the hardware resources of the server, thus greatly reducing the cost of website construction and operation.
Virtual host types supported by httpd:
● domain name-based virtual host (the most widely used)
● virtual host based on IP address
● port-based virtual host
The corresponding characteristic relations are as follows
Same ip, same port, different domain name
Different ip, different port
The ip is the same but the port is different. 1) build an example based on a domain name
Build two virtual web sites
1.www.jj.com
2.www.kk.com
The actual process is as follows:
Use a httpd server to build, ip address is 192.168.68.145. The specific construction process is as follows:
1. Provide domain name resolution for virtual hosts
Install bind and httpd services: 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] # lsdata 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.1www 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.1www 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
Whether the test was successful
[root@localhost named] # cd / etc/httpd/ [root@localhost httpd] # cd conf [root@localhost conf] # lshttpd.conf magic [root@localhost conf] # mkdir extra [root@localhost conf] # lsextra httpd.conf magic [root@localhost conf] # cd extra/ [root@localhost extra] # vim vhost.conf [root@localhost extra] # cat vhost.conf DocumentRoot "/ var/www/html/ll/" ServerName www.ll.com ErrorLog "logs/www.ll.com.error_log" CustomLog "logs/www.ll.com.access_log" common Require all granted DocumentRoot "/ var/www/html/cc/" ServerName www.cc.com ErrorLog "logs/www.cc.com.error_log" CustomLog "logs/www.cc.com.access_log" common Require all granted [root@localhost extra] # vim / etc/httpd/conf/httpd.conf [root@localhost extra] # tail-2 / etc/httpd/conf/httpd.conf IncludeOptional conf. D/*.confInclude conf/extra/vhost.conf [root@localhost extra] # systemctl restart httpd
2) Port-based construction example
According to the above process, you can continue to configure to complete the port-based build:
[root@localhost ~] # vim / etc/httpd/conf/extra/vhost.conf [root@localhost ~] # tail / etc/httpd/conf/extra/vhost.conf DocumentRoot "/ var/www/html/cc02/" ServerName www.cc.com ErrorLog "logs/www.cc02.com.error_log" CustomLog "logs/www.cc02.com.access_log" common Require all granted [root@localhost ~] # cd / var/www/html/ [root@localhost html] # mkdir Cc02 [root@localhost html] # lscc cc02 ll [root@localhost html] # cd cc02/ [root@localhost cc02] # vim index.html [root@localhost cc02] # cat index.html this is cc02 web [root@localhost cc02] # vim / etc/httpd/conf/httpd.conf [root@localhost cc02] # head-43 / etc/httpd/conf/httpd.conf | tail-3Listen 192.168.68.145:80Listen 192.168.68.145:8080#Listen 80 [root@localhost cc02] # systemctl restart httpd
Test verification: just enter http://www.cc02.com:8080/
3) build an example based on IP address [root@localhost cc02] # vim / etc/httpd/conf/extra/vhost.conf [root@localhost cc02] # cat / etc/httpd/conf/extra/vhost.conf DocumentRoot "/ var/www/html/ll/" # ServerName www.ll.com ErrorLog "logs/www.ll.com.error_log" CustomLog "logs/www.ll.com.access_log" common Require all granted DocumentRoot "/ var/www/html/ll02 / "# ServerName www.ll.com ErrorLog" logs/www.ll02.com.error_log "CustomLog" logs/www.ll02.com.access_log "common Require all granted# # DocumentRoot" / var/www/html/cc/ "# ServerName www.cc.com# ErrorLog" logs/www.cc.com.error_log "# CustomLog" logs/www.cc.com.access_log "common# # Require all granted# DocumentRoot" / var/www/html/cc02/ "# ServerName www.cc.com# ErrorLog" logs/www.cc02.com.error_log "# CustomLog" logs/www.cc02.com.access_log "common# # Require all granted# # [root@localhost cc02] # mkdir ll02 [root@localhost cc02] # cd ll02 [root@localhost ll02] # vim index.html [root@localhost ll02] # cat index.html this is ll02 146[ root@localhost ll02] # vim / etc/httpd/conf / httpd.conf [root@localhost ll02] # head-43 / etc/httpd/conf/httpd.conf | tail-matching prevent Apache from glomming onto all bound IP addresses.#Listen 192.168.68.145:80Listen 192.168.68.146:80#Listen 192.168.68.145 purl 8080
Test verification: enter 192.168.68.146
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.