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
1. Introduction Whether the creation time of a fi...
Table of contents What is Docker Compose Requirem...
1. First install the pagoda Installation requirem...
1. MySQL gets the current date and time function ...
The effect is very simple, just copy the following...
1. Introduction to KVM The abbreviation of kernel...
Configure Java environment variables Here, the en...
Web design is both a science and an art. Web desi...
How to solve the problem of 1045 when the local d...
Table of contents TOKEN Timer Refresher 2. Intern...
The equal height layout described in this article...
Environment: init_worker_by_lua, set_by_lua, rewr...
Table of contents 1. Shopping cart example 2. Cod...
In many projects, it is necessary to implement th...
This article shares the specific code for JavaScr...