table of Contents
1. Download
Download the stable version from the official website .
Just unzip it. After decompression, you can see the following directory.
2. Start
There are many ways to start nginx.
(1). Double-click nginx.exe directly.
(2). Open the cmd command window, switch to the decompression directory of nginx, and enter the command nginx.exe or start nginx.
3. Check whether nginx has started successfully
(1). Directly enter the URL http://localhost/:80 in the browser, the following figure appears, indicating that the startup is successful.
(2). Enter tasklist /fi "imagename eq nginx.exe" in the cmd command window, the following means the startup is successful.
The configuration file of nginx is nginx.conf in the conf directory. The port that nginx listens on by default is 80. If port 80 is occupied, it can be changed to an unoccupied port.
The command to check whether 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, there is no need to close nginx and restart nginx, just execute the command nginx -s reload to make the changes take effect.
4. Close nginx
If you use the cmd command window to start nginx, closing the cmd window will not end the nginx process, you can use two methods to close nginx.
(1). Enter the nginx command nginx -s stop (quickly stop nginx) or nginx -s quit (complete and orderly stop nginx)
(Quickly stop nginx) or nginx -s quit (stop nginx completely and orderly)
(2). 使用taskkill taskkill /f /t /im nginx.exe