In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The proposed Web host runs multiple Web sites on the same physical server Each of these sites does not independently occupy a real computer httpd-supported virtual host type, domain name-based virtual host, IP address-based virtual host, port-based virtual host construction experiment, domain name-based virtual host [root@localhost] # yum install bind httpd-y / / install DNS and HTTP services [root@localhost] # cd / etc/ on the server / / enter the etc directory [root@localhost etc] # vim named.conf / / enter the edit DNS service main configuration file. / / omit some of the contents. Options {listen-on port 53 {any }; / / change the listening IP address to any, and listen to all addresses 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;} / / change the hostname to any Allow all hosts to parse... / / omit part of the content.: wq / / Save exit [root@localhost etc] # vim named.rfc1912.zones / / enter the editing area configuration file. / / omit part of the content. Zone "kgc.com" IN { / / change the domain name type master File "kgc.com.zone"; / / change the data file name allow-update {none;};}; zone "aaa.com" IN {/ / change the domain name type master; file "aaa.com.zone" / / change the data file name allow-update {none;};} . / / omit part of the content. [root@localhost etc] # cd / var/named/ enter the region data file storage directory [root@localhost named] # cp-p named.localhost kgc.com.zone / / copy the region data file template [root@localhost named] # vim kgc.com.zone / / enter the editing template $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.144.133 / delete the last line and change it to this line: wq / / Save exit [root@localhost named] # cp-p kgc.com.zone aaa.com.zone / / copy the newly changed data file Named aaa.com.zone There is no need to change the content [root@localhost named] # systemctl start named / / start the DNS service [root@localhost named] # systemctl stop firewalld.service / / close the firewall [root@localhost named] # setenforce 0 / / turn off the enhanced security feature [root@localhost html] # cd / etc/httpd/conf/ enter the http service profile directory [root@localhost conf] # Mkdir extra / / create folder [root@localhost conf] # ls / / View directory extra httpd.conf magic [root@localhost extra] # vim vhost.conf / / Edit subprofile DocumentRoot "/ var/www/html/aaa/" ServerName www.aaa.com ErrorLog "logs/www.aaa.com.error_log" CustomLog "logs / www.aaa.com.access_log "common Require all granted / / Edit virtual host configuration entry DocumentRoot" / var/www/html/kgc/ "ServerName www.kgc.com ErrorLog" logs/www.kgc.com.error_log "CustomLog" logs/www.kgc.com.access_log "common Require all granted ~: wq / / Save and exit [root@localhost extra] # cd / var/www/html/ enter the http service web site [root@localhost html] # mkdir aaa kgc / / create a directory file [root@localhost html] # cd aaa/ enter the directory [root@localhost aaa] # vim index.html / / Edit the default master Page this is aaa web / / Writing content ~: wq / / Save exit [root@localhost aaa] # ls / / View directory index.html [root@localhost aaa] # cd.. / kgc/ return to the upper layer and enter the kgc directory [root@localhost kgc] # vim index.html / / Edit default web page this is kgc web / / Edit content ~: wq / / Save exit [root@localhost kgc] # ls / / View directory index.html [root@localhost kgc] # vim / etc/httpd/conf/httpd.conf / / enter and edit the http service master configuration file. / / omit part of the content. # prevent Apache from glomming onto all bound IP addresses.#Listen 192.168.144.137 ipv4 80 / / Open the ipv4 listening address And change to the native IP address # Listen 80 / / turn off the listening address of ipv6. / / omit part of the content. # Load config files in the "/ etc/httpd/conf.d" directory If any.IncludeOptional conf.d/*.confInclude conf/extra/vhost.conf / / add a subprofile directory entry on the last line: wq / / Save exit [root@localhost kgc] # systemctl start httpd / / enable http service [root@localhost kgc] # netstat-ntap | | grep 80 / / check whether port 80 is enabled for tcp6 0 0: 80: * LISTEN 2450/httpd |
Open a win10 client, change the DNS server address, open a web page, and test the success of building a virtual host based on different domain names
Build virtual host based on port
In this experiment, we will directly change the configuration in the above experiment without reoperating it.
[root@localhost named] # vim / etc/httpd/conf/extra/vhost.conf...// omits part of the content. DocumentRoot "/ var/www/html/kgc/" ServerName www.kgc.com ErrorLog "logs/www.kgc.com.error_log" CustomLog "logs/www.kgc.com.access_log" common Require all granted DocumentRoot "/ var/www/html/kgc02/" ServerName www.kgc.com ErrorLog "logs/www.kgc02.com.error_log" CustomLog "logs/www.kgc02.com.access_log" common / / copy the configuration file entry above and change the listening port to 8080 And put the site directory, Change the log file name to kgc02 Require all granted: wq / / Save exit [root@localhost named] # cd / var/www/html/ [root@localhost html] # mkdir kgc02 [root@localhost html] # cd kgc02/ [root@localhost kgc02] # vim index.htmlthis is kgc02 web~:wq [root@localhost kgc02] # vim / etc/httpd/conf/httpd.conf...// omit part. # prevent Apache from glomming Onto all bound IP addresses.#Listen 192.168.144.137:80Listen 192.168.144.137:8080#Listen 80... root@localhost kgc02 / omitted part of the content.: wq [root@localhost kgc02] # systemctl restart httpd
Verify the port-based virtual host configuration on the win10 client
Establishment of virtual host based on IP address
Here, add a network card to the Linux server virtual machine to obtain another IP address
Get the IP address in the virtual machine
[root@localhost ~] # ifconfig / / View network card information ens33: flags=4163 mtu 1500 inet 192.168.144.137 netmask 255.255.255.0 broadcast 192.168.144.255 inet6 fe80::a85a:c203:e2e:3f3c prefixlen 64 scopeid 0x20 inet6 fe80::ad78:663f:1f02:22e4 prefixlen 64 scopeid 0x20 ether 00:0c:29:72:65:cb txqueuelen 1000 (Ethernet) RX packets 14117 bytes 10290025 ( 9.8 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 6337 bytes 767788 (749.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens36: flags=4163 mtu 1500 inet 192.168.144.143 netmask 255.255.255.0 broadcast 192.168.144.255 / / successfully obtained IP address inet6 fe80::d65e:47b1:916d:de6c prefixlen 64 scopeid 0x20 ether 00:0c:29:72:65 : D5 txqueuelen 1000 (Ethernet) RX packets 115 bytes 20495 (20.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 79 bytes 17837 (17.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0. [root@localhost ~] # vim / etc/httpd/conf/extra/vhost.conf / / enter the edit http service sub-profile / / change to fixed IP address DocumentRoot "/ var/www/html/aaa/" ServerName www.aaa.com ErrorLog "logs/www.aaa.com.error_log" CustomLog "logs/www.aaa.com.access_log" common Require all granted / / copy the above configuration bar Change IP address DocumentRoot "/ var/www/html/aaa02/" / / change site file ServerName www.naaa.com / / change domain name ErrorLog "logs/www.aaa02.com.error_log" / / change error log file name CustomLog "logs/www.aaa02.com.access_log" common / / change log file name Require all granted: wq / / Save and exit [root@localhost ~] # vim / etc/named.rfc1912.zones / / Edit DNS zone configuration file. / / omit some of the contents. Zone "aaa.com" IN {type master File "aaa.com.zone"; allow-update {none;};}; zone "naaa.com" IN {type master; / / add a new zone profile file "naaa.com.zone"; allow-update {none;};} ...: wq / / Save exit [root@localhost] # cd / var/named/ enter the region data file storage directory [root@localhost named] # cp-p aaa.com.zone naaa.com.zone / / copy the area data file [root@localhost named] # vim naaa.com.zone / / enter Edit the new zone data file $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.144.143 / change the IP address ~: wq / / Save exit [root@localhost named] # cd / var/www/html/ enter the http service site [root@localhost html] # mkdir aaa02 / / create a new site Click the directory [root@localhost html] # cd aaa02/ enter the directory [root@localhost aaa02] # vim index.html / / Edit the default home page file this is 143aaa02 web / / Edit the web content: wq / / Save and exit [root@localhost aaa02] # vim / etc/httpd/conf/httpd.conf / / Edit the http service master configuration Set part of the file. / / omit part of the content. # prevent Apache from glomming onto all bound IP addresses.#Listen 192.168.144.137:80Listen 192.168.144.143 IP 80 / / Editor listens to the new IP address # Listen 80. Take / leave part of the content.: wq / / Save exit [root@localhost Aaa02] # systemctl restart httpd / / restart the http service [root@localhost aaa02] # systemctl restart named / / restart the DNS service
Verify the virtual host based on IP address in the win10 client
Configuration successful
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.