How to configure Nginx multiple domain names under windows

王林
Release: 2023-06-02 21:43:54
forward
1990 people have browsed it

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;
}
Copy after login

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;
    }
}
Copy after login

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;
    }
}
Copy after login

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
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!