Set up Nginx server configuration - name-based virtual hosting

1 line installation

  yum install -y nginx

2 three copies of configuration files

  cd /etc/nginx/conf.d

  cp default.conf name1.conf

  cp default.conf name2.conf

  cp default.conf name3.conf

3 modify three configuration files

Domain respectively corresponding to a.com b.com c.com html1, html2, html3

  vim name1.conf

 

a.com

  vim name2.conf

 

b.com

  vim name3.conf

 

c.com

4 Create a web page

  echo "a.com">/opt/app/html1/index.html

  echo "b.com">/opt/app/html2/index.html

  echo "c.com">/opt/app/html3/index.html

 

web content

5 for local dns resolution

 

The local resolver

Format: IP [space] domain name, an IP may correspond to multiple domain names, but one IP must be written on one line

6 Start Nginx

   systemctl start nginx

Common restart: nginx -s reload

7 Test

 

Local test

Using a local test, to test directly borrowed curl

Guess you like

Origin blog.csdn.net/VictoryKingLIU/article/details/91789039