Experimental environment A minimally installed CentOS 7.3 virtual machine Configure the basic environment 1. Install nginx yum install -y epel-* yum isntall -y nginx vim 2. Create the site root directory of the virtual machine host mkdir /var/wwwroot mkdir /var/wwwroot/site1 mkdir /var/wwwroot/site2 echo -e "site1" >> /var/wwwroot/site1/index.html echo -e "site2" >> /var/wwwroot/site2/index.html 3. Disable CentOS firewall setenforce 0 systemctl stop firewalld systemctl disable firewalld Configuring port-based virtual hosts 1. Edit the nginx configuration file vim /etc/nginx/conf.d/vhosts.conf 2. Add the following content server { listen 8081; root /var/wwwroot/site1; index index.html; location / { } } server { listen 8082; root /var/wwwroot/site2; index index.html; location / { } } 3. Start systemctl start nginx 4. Access two sites on the host Configuring domain-based virtual hosts 1. Re-edit the nginx configuration file vim /etc/nginx/conf.d/vhosts.conf 2. Delete the original content and add the following content again server { listen 80; server_name site1.test.com; root /var/wwwroot/site1; index index.html; location / { } } server { listen 80; server_name site2.test.com; root /var/wwwroot/site2; index index.html; location / { } } 3. Restart systemctl restart nginx 4. Modify the Edit Add the following content (modify according to actual situation) 5. Access two sites on the host Configuring IP-based virtual hosts 1. Add two IP addresses to the virtual machine ifconfig ens33:1 192.168.204.151 ifconfig ens33:2 192.168.204.152 2. Re-edit the nginx configuration file vim /etc/nginx/conf.d/vhosts.conf 3. Delete the original content and add the following content again server { listen 192.168.204.151:80; root /var/wwwroot/site1; index index.html; location / { } } server { listen 192.168.204.152:80; root /var/wwwroot/site2; index index.html; location / { } } 4. Restart systemctl restart nginx 5. Access two sites on the host 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:
|
<<: Solve the problem of shrinking Mysql transaction log and log files being too large to shrink
>>: JavaScript implements circular carousel
Introduction to the usage of MySQL keyword Distin...
Two cases: 1. With index 2. Without index Prerequ...
Features of MySQL: MySQL is a relational database...
Table of contents 1. Form events 2. Mouse events ...
Method 1 Copy code The code is as follows: documen...
Note: The basic directory path for software insta...
Events can specify the execution of SQL code once...
Click here to return to the 123WORDPRESS.COM HTML ...
When the existing video player cannot meet the ne...
Table of contents 1. Integrate Ant Design Vue 2. ...
Table of contents 1. Overview 2. Routing Navigati...
Overview As for the current default network of Do...
Today I'd like to introduce a countdown made ...
Regarding the high-performance distributed memory...