1. Download Nginx
http://nginx.org/en/download.html Download stable version, take nginx/windows-1.12.2 as an example, download directly nginx-1.12.2.zip
Unzip after download, unzip as follows
2. Start Nginx
There are a number of ways to start Nginx
(1) Directly double-click the Nginx.exe, double-click on a black pop-up window flashed over
(2) Open cmd Command window, switch to nginx extract directory, enter command Nginx.exe or start Nginx, enter can
3. Check if Nginx is started successfully
Enter the URL directly in the browser address bar http://localhost:80, carriage return, the following page shows the success of the launch
You can also enter the command tasklist/fi "imagename eq nginx.exe" in the cmd command window, and the following results show that the startup was successful
Nginx configuration file is the nginx.conf in the Conf directory, the default configuration of the Nginx listener port is 80, if the 80 port is occupied can be modified to an unoccupied port
The command to check if Port 80 is occupied is: Netstat-ano | findstr 0.0.0.0:80 or Netstat-ano | Findstr "80"
When we modify the Nginx configuration file nginx.conf, do not need to shut down Nginx and restart Nginx, only need to execute the command nginx-s reload can be changed to take effect
4. Close Nginx
If you use the CMD command window to start Nginx, close the cmd window will not end the Nginx process, you can use two methods to close Nginx
(1) Input nginx command nginx-s stop (Fast stop nginx) or Nginx-s quit (complete and orderly stop Nginx)
(2) Use Taskkill taskkill/f/t/im nginx.exe
5. Load balancing with Nginx proxy server
We can modify the Nginx configuration file nginx.conf to access the Nginx proxy server when the purpose of jumping to the specified server, that is, through the Proxy_pass configuration request forwarding address, that is, when we still input http://localhost:80, The request jumps to the server we configured
Similarly, we can configure multiple target servers, when one server fails, Nginx can automatically turn the request to another server, for example, the configuration is as follows:
When the server localhost:8080 hangs, Nginxnginx can automatically turn the request to the server 192.168.101.9:8080. It also adds a weight property that represents the weights that each server is accessing, weight
The higher the chance of being accessed.
2018-06-14 Update
Be careful not to double-click on the Nginx.exe, which will cause the configuration to restart after modification, stop nginx Invalid, you need to manually close all the Nginx process in the Task Manager
Installation of Nginx on Windows and Configuration and optimization of Nginx