1. Apache server installation and configuration yum install httpd -y systemctl start httpd &&systemctl enable httpd systemctl stop firewalld setenforce 0 //Set the selinux security level to premise and the reboot will fail. Use the local Windows browser to test the virtual machine's IP address (be sure to turn off the firewall). If you see the following interface, it means that HTTP is successfully started. 2. Apache2 configuration file After httpd is installed, the /etc/httpd directory will be automatically generated Main configuration file: conf/httpd.conf 3. Based on IP address (the server requires multiple public IP addresses)
(1) Bind another IP address to the server (2) Add a site file lyn1.conf in the /etc/httpd/conf.d directory You can also configure it directly in /etc/httpd/conf/httpd.conf. The httpd.conf file will automatically import the files in /etc/httpd/conf.d. For convenience, we write it directly to the /etc/httpd/conf.d folder. mkdir /mnt/lyn1 cd /etc/httpd/conf.d vi lyn1.conf <VirtualHost 192.168.100.135> //Local IP addressDocumentRoot /mnt/lyn1/ //Network data directoryServerName www.lyn1.com //Domain name of the website server<Directory /mnt/lyn1/ > //Website data directory permissionsAllowOverride None //Do not allow overwritingRequire all granted //Allow all access requests</Directory> </VirtualHost> (3) Add the webpage file index.html to the publishing directory of the corresponding website of shiyan1.com vi /mnt/lyn1/index.html <html> <head> <title>lyn1</title> </head> <body> <h1>lyn1</h1> this is the www.lyn1.com website </body> </html> (4) Add a site file lyn2.conf in the /etc/httpd/conf.d directory mkdir /mnt/lyn1 cd /etc/httpd/conf.d vi lyn1.conf <VirtualHost 192.168.100.136> //Another IP address of this machineDocumentRoot /mnt/lyn2/ //Network data directoryServerName www.lyn2.com //Domain name of the website server<Directory /mnt/lyn2/ > //Permissions for the website data directoryAllowOverride None //Do not allow overwritingRequire all granted //Allow all access requests</Directory> </VirtualHost> vi /mnt/lyn2/index.html <html> <head> <title>lyn2</title> </head> <body> <h1>lyn2</h1> this is the www.lyn2.com website </body> </html> (6) Restart the Apache server and verify using a browser systemctl restart httpd 4. Configure virtual hosts based on port numbers
(1) Add listening port 81 to the main configuration file /etc/httpd/conf/httpd.conf
(2) Modify the /etc/httpd/conf.d/lyn1.conf file: <VirtualHost 192.168.100.135:80> ServerName www.lyn1.com DocumentRoot /var/www/html/lyn1/ <Directory /var/www/html/lyn1/ > AllowOverride None Require all granted </Directory> </VirtualHost> (3) Modify the /etc/httpd/conf.d/shiyan2.conf file: <VirtualHost 192.168.100.135:81> ServerName www.lyn2.com DocumentRoot /var/www/html/lyn2/ <Directory /var/www/html/lyn2/ > AllowOverride None Require all granted </Directory> </VirtualHost> (4) Restart the Apache server and verify using a browser systemctl restart httpd 5. Configure a hostname-based virtual machine
(1) Register DNS (configure DNS server and implement normal resolution). For temporary testing, you can use the /etc/hosts modification method. Here, the hosts modification method is used. #vi /etc/hosts
(2) In the main configuration file /etc/httpd/conf.d/lyn1.conf <VirtualHost *:80> ServerName www.lyn1.com DocumentRoot /var/www/html/lyn1/ <Directory /var/www/html/lyn1/ > AllowOverride None Require all granted </Directory> </VirtualHost> (3) In the main configuration file /etc/httpd/conf.d/lyn2.conf <VirtualHost *:81> ServerName www.lyn2.com DocumentRoot /var/www/html/lyn2/ <Directory /var/www/html/lyn2/ > AllowOverride None Require all granted </Directory> </VirtualHost> (4) Restart the apache2 server and verify
To access a website under Windows, add the following two lines to the C:\Windows\System32\drivers\etc\hosts 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:
|
<<: JavaScript to achieve skin effect (change background)
>>: Vue-router example code for dynamically generating navigation menus based on backend permissions
How to solve the problem of forgetting the root p...
The solution to forgetting the initial password o...
I recently deployed and tested VMware Horizon, an...
1. Environmental Preparation The IP address of ea...
Three Paradigms 1NF: Fields are inseparable; 2NF:...
If you are a developer looking to get into the wo...
Preface Since the most important data structure i...
As shown below: CSS CodeCopy content to clipboard...
1. Command Introduction time is used to count the...
◆Add to favorites illustrate Click to add your we...
Or write down the installation process yourself! ...
A Multi-Select is a UI element that lists all opt...
Scrcpy Installation snap install scrcpy adb servi...
Scenario Requirements 1. We can use the script fu...
This article shares with you the specific method ...