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
<br />Before browsers can handle the next ge...
MySQL 8.0.19 supports locking the account after e...
This article shares the specific code of react+an...
The image integration technology used by American...
This article describes how to install opencv with...
Count(*) or Count(1) or Count([column]) are perha...
Table of contents definition structure Examples C...
Create your first web page in one minute: Let'...
Table of contents 1. Introduction 1. Basic layout...
First look at the effect: html <a href="#...
For example, he enters: XML/HTML Code div#page>...
1. Introduction I recently upgraded my blog and a...
How to reset the initial value of the auto-increm...
Use JS to complete a simple calculator for your r...
Since I have parsed HTML before, I want to use Vu...