1. Same IP address, different port numbers Virtual host 1: The host IP address is 172.16.30.20, the port number is 80 (default port), the DocumentRoot is /var/www/vhost1, and the virtual host site homepage file is created under the DocumentRoot directory. [root@rhel7 ~]# cd /var/www/ [root@rhel7 www]# mkdir vhost1 [root@rhel7 www]# cd vhost1/ [root@rhel7 vhost1]# vim index.html [root@rhel7 vhost1]# cat index.html this is the vhost1 Virtual host 2: The host IP address is 172.16.30.20, the port number is 8080, the DocumentRoot is /var/www/vhost2, and the virtual host site homepage file is created under the DocumentRoot directory. [root@rhel7 ~]# cd /var/www/ [root@rhel7 www]# mkdir vhost2 [root@rhel7 www]# cd vhost2/ [root@rhel7 vhost2]# vim index.html [root@rhel7 vhost2]# [root@rhel7 vhost2]# cat index.html this is the vhost2 Edit the virtual machine host configuration file httpd-vhosts.conf [root@rhel7 ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf <VirtualHost 172.16.30.10:80> DocumentRoot "/var/www/vhost1" </VirtualHost> Listen 8080 <VirtualHost 172.16.30.10:8080> DocumentRoot "/var/www/vhost2" </VirtualHost> [root@rhel7 ~]# systemctl restart httpd [root@rhel7 ~]# firewall-cmd --add-port=8080/tcp --permanent success [root@rhel7 ~]# firewall-cmd --reload success Access Test: 2. Different IP addresses, same port number Virtual host 1: The host IP address is 172.16.30.20, the port number is 80 (default port), the DocumentRoot is /var/www/vhost1, and the virtual host site homepage file is created under the DocumentRoot directory. Virtual host 2: The host IP address is 172.16.30.200, the port number is 80 (default port), the DocumentRoot is /var/www/vhost2, and the virtual host site homepage file is created under the DocumentRoot directory. [root@rhel7 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33 TYPE=Ethernet BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 UUID=bde41fa3-f559-4de2-ba9a-857fed211aac DEVICE=ens33 ONBOOT=yes DNS1=127.0.0.1 ZONE=public IPADDR=172.16.30.10 PREFIX=24 IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPADDR1=172.16.30.100 PREFIX1=24 [root@rhel7 ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf <VirtualHost 172.16.30.10:80> DocumentRoot "/var/www/vhost1" </VirtualHost> <VirtualHost 172.16.30.100:80> DocumentRoot "/var/www/vhost2" </VirtualHost> [root@rhel7 ~]# systemctl restart httpd Access Test: 3. Same IP address, same port number, different FQDN Virtual host 1: The host IP address is 172.16.30.20, the port number is 80 (default port), the FQDN is vhost1.example.com, the DocumentRoot is /var/www/vhost1, and the virtual host site homepage file is created in the DocumentRoot directory. Virtual host 2: The host IP address is 172.16.30.20, the port number is 80 (default port), the FQDN is vhost2.example.com, the DocumentRoot is /var/www/vhost2, and the virtual host site homepage file is created in the DocumentRoot directory. [root@rhel7 ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf <VirtualHost 172.16.30.10:80> DocumentRoot "/var/www/vhost1" ServerName vhost1.example.com </VirtualHost> <VirtualHost 172.16.30.10:80> DocumentRoot "/var/www/vhost2" ServerName vhost2.example.com </VirtualHost> Note: The corresponding resolution content needs to be added in the DNS server. Access Test: Remember to restart the service every time you modify the configuration file. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: How to view mysql binlog (binary log)
>>: Solve the cross-domain problem of get and post requests of vue $http
Recently, due to business adjustments in the comp...
Table of contents Preface 1. Technical Principle ...
<input> is used to collect user information ...
Table of contents first step Step 2 Step 3 Step 4...
Install CentOS 7 after installing VirtualBox. I w...
1. Install MySQL software Download and install My...
First, let's explain the network setting mode...
1. Create a new virtual machine in VMware 15.5 1....
This article shares the installation and configur...
The following operation demonstrations are all ba...
HTML 4 HTML (not XHTML), MIME type is text/html, ...
Preface Query optimization is not something that ...
In the SQL like statement, for example SELECT * F...
The first step is to download the free installati...
Table of contents 1. Virtual Host 1.1 Virtual Hos...