Table of contents
1. The root directory of ip+port 1
Second, the root directory of ip+port 2
Write a virtual host configuration file
The configuration is complete, and the experimental results are tested
Create a website directory
1. The root directory of ip+port 1 //This directory is free for everyone, and can be synchronized in the configuration file
①: mkdir -p /www/port/9090 //The directory created here is 9090 because the port we want to test is 9090 for easy memory, you can modify it to the port number you want to test
②: touch index.html //Make sure it is created under the /www/port/9091 directory, you can enter a sentence in index.html and then we will test whether the website is successfully created
Second, the root directory of ip+port 2
①:mkdir -p /www/port/9091
②:touch index.html
Write a virtual host configuration file
1. Enter the /etc/httpd/conf.d directory to create the myhost.conf configuration file
//Create configuration file touch myhost.conf
Two: Write the myhost.conf configuration file
Listen 192.168.188.67:9090 //This ip must exist, you can check the ip of your network card with ipconfig first,
Listen 192.168.188.67:9091 //If the port number of the test is not 9091or9090, just modify it
<Directory "/www/port"> //Give us /www/port/9090or9091 website directory permission
AllowOverride None
Require all granted
</Directory>
<VirtualHost 192.168.188.67:9090> //If you are not testing port 9090, you need to change it to a test port
DocumentRoot /www/port/9090 //The root directory of the website, you can modify it according to the synchronization you created
</VirtualHost>
<VirtualHost 192.168.188.67:9091>
DocumentRoot /www/port/9091
</VirtualHost>
The configuration is complete, and the experimental results are tested
1. Restart the httpd service
systemctl restart httpd
2. Use the netstat -ant command to check whether the ip+port in the configuration file is successfully enabled for monitoring
3. Access the ip+different ports of linux through the windows browser
①: Access 192.168.188.67:9090
②: Access 192.168.188.67:9091