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
Table of contents Overview first step Step 2 Why ...
Table of contents 1. Demand 1. Demand 2. SDK para...
Deploy the MySQL environment locally (192.168.1.1...
Table of contents What is ref How to use ref Plac...
3D coordinate concept When an element rotates, it...
Common methods for limiting input 1. To cancel the...
js interesting countdown case, for your reference...
1. Principle of Hotlinking 1.1 Web page preparati...
1. Introduction This article will show you how to...
Tomcat itself optimization Tomcat Memory Optimiza...
Export a single table mysqldump -u user -p dbname...
I encountered such a problem when doing the writte...
In previous development, we used the default attr...
Table of contents Message Board Required librarie...
This article uses examples to illustrate how to i...