Article Directory
1. Overview
1. Virtual Web Hosting
Run multiple Web sites on the same server, each of which does not occupy a real computer independently
2. Types of virtual hosts supported by httpd
- Domain name-based virtual hosting
- Virtual host based on IP address
- Port-based virtual hosting
3. Apache access control
- Function
Control access to website resources
Add access authorization to specific website directories - Common access control methods
Client address restrictions
User authorization restrictions
4. Apache connection keeps relevant parameters
1. KeepAlive
◆Whether the connection is kept open, OFF is closed, ON is opened
2. KeepAlive Timeout
◆The maximum interval time between multiple requests for one connection, the connection is disconnected after two requests exceed this time
3. MaxKeepAliveRequests
◆- -The second long connection can The maximum number of requests transferred
can be added in two ways, as shown below
2. Experimental steps
Experiment preparation
CenOS 7: Dual network cards, both in NAT mode
Win10: Single network card, using NAT mode
1. Configure DNS for domain name
1.1, configure dual network cards
ens33 : 192.168.235.135
ens36: 192,168,235,137
1.2, install apache related services
yum install httpd bind -y
1.3, edit the configuration file
vim /etc/named.conf
1.4, edit zone configuration file
vim /etc/named.rfc1912.zones
1.5, edit area details configuration file
cd / var / named
cp -p named.localhost kgc.com.zone
vim kgc.com.zone
1.6, copy files
cp -p kgc.com.zone benet.com.zone
1.7, start the service
systemctl start named
1.8, turn off the firewall
iptables -F
setenforce 0
1.9, DNS modification of win10
The DNS of win10 is modified to: 192.168.235.135
1.10, test
nslookup www.kgc.com
nslookup www.benet.com
2. Construct virtual host-based on domain name
2.1, enter the configuration file directory
cd /etc/httpd/conf/
2.2. Create directories and files and edit
mkdir extra
cd extra /
vim vhost.conf
2.3, restart the service
systemctl start httpd
2.4, enter the website directory
cd / var / www / html
ls
2.5, create a directory
mkdir kgc benet
cd kgc
vim index.html
cd …
cd benet
vim index.html
2.6, edit the configuration file
vim /etc/httpd/conf/httpd.conf
2.7, restart the service
systemctl restart httpd
2.8, test
3. Build a virtual host-port based
3.1, enter the configuration file directory
cd /etc/httpd/conf/extra
3.2, edit the configuration file
vim vhost.conf
3.3, create a directory
mkdir / var / www / html / benet02
vim /var/www/html/benet02/index.html
3.4, edit the configuration file
vim /etc/httpd/conf/httpd.conf
3.5, restart the service
systemctl restart httpd
3.6, view the process used by httpd
netstat -ntap | grep httpd
3.7, test
4. Build a virtual host-based on IP address
4.1, enter the configuration file directory
cd /etc/httpd/conf/extra
4.2, edit the configuration file
vim vhost.conf
4.3, create a directory
mkdir /var/www/html/kgc02
4.4. Create home page file
vim /var/www/html/kgc02/index.html
4.5. Edit the configuration file
vim /etc/httpd/conf/httpd.conf
4.6, restart the service
systemctl restart httpd
4.7, view the process of httpd
netstat -ntap | grep httpd