In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Construction of virtual hosts 1. Introduction of virtual hosts there are three types of virtual hosts commonly used in enterprises:
(1) based on domain name
(2) Port-based
(3) based on IP
Virtual web host
Running multiple web sites on the same physical server, each of which does not independently occupy a real computer
Virtual host types supported by httpd
(1) Virtual host based on domain name
(2) Virtual host based on IP address
(3) Port-based virtual host
Apache connection retention Apache connection retention related parameters
(1) KeepAlive
Whether to open and keep the connection, OFF closed, ON open.
(2) KeepAlive Timeout
The maximum interval between multiple requests for a connection, after which the connection is disconnected
(3) MaxKeepAliveRequests
The maximum number of requests that can be transmitted at a time
Apache access control
(1) function
Control access to website resources
Add access to a specific site directory
(2) commonly used access control methods
Client address limit
User restriction
Access control based on client address uses Require configuration items to implement access control, in order to restrict the common syntax Require all grantedRequire all deniedRequire localRequire [not] host Require [not] ip that can be used for Require configuration items in, and configuration segments
When using not to prohibit access, you should place it in the container and specify the appropriate restriction policy in the container.
Command mode of Require
2. Build a virtual host-- configure the environment based on domain name 2.1
Install DNS and httpd services
[root@localhost ~] # yum install bind httpd-y
Modify the DNS main configuration file
[root@localhost ~] # vim / etc/named.conf
Configure the DNS zone profile
[root@localhost ~] # vim / etc/named.rfc1912.zones # add the following to the zone configuration file: zone "kgc.com" IN {type master; file "kgc.com.zone"; allow-update {none;};}; zone "accp.com" IN {type master; file "accp.com.zone"; allow-update {none;};}
Configure the DNS zone data profile
[root@localhost ~] # cd / var/named/ [root@localhost named] # ls / / View data dynamic named.ca named.empty named.localhost named.loopback slaves [root@localhost named] # cp-p named.localhost kgc.com.zone [root@localhost named] # vim kgc.com.zon
Copy a copy of the regional data configuration file of kgc to accp without modification
[root@localhost named] # cp-p kgc.com.zone accp.com.zone
Enable DNS services, turn off firewall and security features
[root@localhost named] # systemctl start named [root@localhost named] # systemctl stop firewalld.service [root@localhost named] # setenforce 02.2 configure a static DNS resolution address on the tested windows10
Open cmd on windows10 to test whether the domain name can be resolved
2.3 configure virtual host [root@localhost named] # cd / etc/httpd/ [root@localhost httpd] # lsconf conf.d conf.modules.d logs modules run [root@localhost httpd] # cd conf/ [root@localhost conf] # lshttpd.conf magic [root@localhost conf] # mkdir extra [root@localhost conf] # cd extra/ [root@localhost extra] # vim vhost.conf / / create an extension file / / header Fixed format DocumentRoot "/ var/www/html/kgc" / / site ServerName www.kgc.com / / domain name ErrorLog "logs/www.kgc.com.error_log" / / error log file CustomLog "logs/www.kgc.com.access_log" common / / access log file Require all granted / / access DocumentRoot "/ var/www/html/accp" ServerName www.accp.com ErrorLog "logs/www.accp.com.error_log" CustomLog "logs/www.accp.com.access_log" common Require all granted
Configure the display of a web page
[root@localhost httpd] # cd / var/www/html/ [root@localhost html] # ls [root@localhost html] # mkdir kgc accp [root@localhost html] # lsaccp kgc [root@localhost html] # cd kgc/ [root@localhost kgc] # vim index.htmlthis is kgc web [root@localhost kgc] # cd.. / accp/ [root@localhost accp] # vim index.htmlthis is accp web
Configure the absolute path to the web page
[root@localhost accp] # cd / etc/httpd/ [root@localhost httpd] # lsconf conf.d conf.modules.d logs modules run [root@localhost httpd] # cd conf/ [root@localhost conf] # vim httpd.confInclude conf/extra/vhost.conf
Start the http service
[root@localhost conf] # systemctl start httpd2.4 tests his web page on windows10
3. Build a virtual host-- modify the extension file based on the domain name based on port 3.1, and configure the Add a port [root@localhost conf] # cd extra/ [root@localhost extra] # vim vhost.conf 22 DocumentRoot "/ var/www/html/accp02" 23 ServerName www.accp.com 24 ErrorLog "logs/www.accp02.com.error_log" 25 CustomLog "logs/www.accp02.com.access_log" common 26 27 Require all granted 28 29 [root@localhost extra] # cd / var/www/html/ / / create accp02 zhandian [root@localhost html] # lsaccp kgc [root@localhost html] # mkdir accp02 [root@localhost html] # cd accp02/ [root@localhost accp02] # vim index.htmlthis is accp02 web
Enter the absolute path, modify
[root@localhost accp02] # vim / etc/httpd/conf/httpd.conf
Restart the web service
[root@localhost accp02] # systemctl restart httpd
View Port
[root@localhost accp02] # netstat-ntap
3.2 enter the windows10 test
4. Build a virtual host-- based on IP4.1 configuration environment
Based on the fact that IP wants different IP addresses, we first add a network card to the virtual machine, and then let him obtain the IP address automatically.
The second network card was added successfully. His IP address is 192.168.45.128.
Enter the vhost.conf to modify and set the configuration of the base IP
[root@localhost accp02] # cd / etc/httpd/conf/extra/ [root@localhost extra] # vim vhost.conf 12 DocumentRoot "/ var/www/html/kgc" 3 ErrorLog "logs/www.kgc.com.error_log" 4 CustomLog "logs/www.kgc.com.access_log" common 5 6 Require all granted 7 8 9 10 11 DocumentRoot "/ var/www/html/kgc02" 12 ErrorLog " Logs/www.kgc02.com.error_log "13 CustomLog" logs/www.kgc02.com.access_log "common 14 15 Require all granted 16 17
Create a web page file and add web page display content
[root@localhost extra] # cd / var/www/html/ [root@localhost html] # mkdir kgc02 [root@localhost html] # cd kgc02/ [root@localhost kgc02] # vim index.htmlthis is kgc02 web
Enter the http configuration file
[root@localhost kgc02] # vim / etc/httpd/conf/httpd.conf
Restart the web service
[root@localhost kgc02] # systemctl restart httpd4.2 returns to the windows10 test page
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.