If a server has only one IP or needs to access different virtual hosts through different ports, you can use a port-based virtual host configuration.
(1) on the CENTOS7 server of the virtual machine, configure Eth0:4 to 192.168.1.214:
(2) Configure the/etc/hosts file for easy testing:
Do a ping test to see if the IP address is on:
(3) Establish a virtual host to store the root directory of the Web page, and set up home file index.html
(4) Modify the/usr/local/apache2/conf/httpd.conf file to add the following at the end of the file:
192.168. 1.214:8080192.168. 1.214:8081192.168. 1.214:8082
(5) Edit the configuration file for each IP port
In the/usr/local/apache2/conf/vhost/directory, create a new porttest.8080.conf, porttest.8081.conf, porttest.8082.conf file to porttest.8080.conf file as an example:
192.168. 1.214:8080> ServerName porttest documentroot /usr/local/apache2/www/ porttest/8080 "/usr/local/apache2/www/porttest/8080/"> Options Indexes followsymlinks allowoverride None Require all granted </Directory></VirtualHost>
(6) Test the configuration file and restart the Apache server
(i) using the APACHECTL-T command to test if the configuration file is correct, restart the Apache server with the apachectl restart command:
(ii) test the opening of a virtual host using the Curl command:
The display cannot be connected. It is only then remembered that the firewall does not open 8080,8081,8082 these ports, open:
Vim/etc/sysconfig/iptables
Restart Iptables:
Then connect the porttest:8080 with the Curl command, resulting in a series of errors such as:
Baffled why the 192.168.1.214 8080,8081,8082 port is not open, but the 192.168.1.213 of the three ports opened. Recheck all the above steps, finally found in the fourth step, will be wrong to Listen 192.168.1.214:8080 written 192.168.1.213:8080:
Oh, the effect of ... To correct it:
(iii) test the Apache configuration correctly and, if correct, restart the Apache service:
Test with the Curl command:
Browser testing for Windows hosts:
Success!
CentOS 7 Operations Management notes (6)----Apache Port-based virtual host configuration