Home  >  Article  >  Operation and Maintenance  >  How to configure Nginx multiple domain names under windows

How to configure Nginx multiple domain names under windows

王林
王林forward
2023-06-02 21:43:541943browse

1. The directory structure for installing nginx under windows is as follows:

How to configure Nginx multiple domain names under windows

2. Contents of conf/nginx.conf in the nginx-1.12.1 directory

#user nobody;
worker_processes 1;
events {
  worker_connections 1024;
}
http {
  include    mime.types;
  default_type application/octet-stream;
  sendfile    on;
  keepalive_timeout 65;
  server {
    listen    80 default_server;
    server_name localhost default_server;
    root  html;
    location / {
      index index.html index.htm;
    }
}
  include ../vhost/*.conf;
}

3. Contents of a_com.conf under the vhost directory:

server {
    listen    80;
    server_name www.a.com;
    root  d:/test/;
    location / {
      index index.html index.htm;
    }
}

4. Contents of b_com.conf under the vhost directory:

server {
    listen    80;
    server_name www.b.com;
    root  d:/test2/;
    location / {
      index index.html index.htm;
    }
}

5. Create new test and test2 directories under the d disk of the local disk, And create a new index.html file

6. Modify hosts under c:\windows\system32\drivers\etc in the local disk c drive as follows

127.0.0.1    www.a.com
127.0.0.1    www.b.com

7. Use cmd to enter the nginx installation directory Execute

nginx.exe Start

nginx -t //Detect syntax

nginx -s reload //Restart

nginx -s stop // Stop

8. Open the browser and enter the URL

The above is the detailed content of How to configure Nginx multiple domain names under windows. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete