1. Install Nginx
1.1 Unzip and start Nginx
Unzip the downloaded file nginx-1.16.1
, open the cmd window cd
to the root directory, and start Nginx
start Nginx through the startup command:
When pressing Enter, the window will flash for a while. At this time, service 1 has been successfully started. We can use the console command to netstat -ano | findstr :80 | findstr LISTENING
check whether port 80 has been monitored.
As you can see, the 80
port is already listening. Open the browser and enter: http://localhost:80
You can visit the Nignx welcome page.
1.2 Stop Nginx
Stopping Nginx
is also very simple. Execute in the root directory nginx -s stop
to stop the Nginx service. There is another way nginx -s quit
to exit all Nginx services by command.
2. View Nginx commands
Common parameters | effect |
---|---|
nginx -v | Nginx version information |
nginx -V | Details, including compiled modules |
nginx -t | Followed by the configuration file address, check whether the syntax of the configuration file is correct |
nginx -c | Specify the Nginx configuration file |
nginx -s | The most important options, stop | quit: stop the Nginx service, reload: start the Nginx service with hot reload, reopen: reopen the log file |
3. Nginx preliminary configuration
The basic configuration of Nginx can be divided into the following five parts:
- Initial configuration
- basic grammar
- http service configuration
- tcp/udp
- reverse proxy
…