The window10 system installs the nginx service to provide web page services. The following is a detailed graphic installation and configuration tutorial.
1) Download nginx software
Official download address: http://nginx.org/en/download.html
2) Decompression software
unzip nginx-1.20.1.zip or use decompression software, the following is the decompressed content
3) CMD command line starts nginx
cd nginx-1.20.1
start nginx
nginx -t
tasklist /fi "imagename eq nginx.exe"
nginx -s reload //Reload
nginx -s stop //This method is equivalent to first finding out the nginx process id and then using the kill command to force Kill the process
nginx -s quit //The stop step of this method is to stop after the nginx process finishes processing tasks
illustrate:
- The decompressed Nginx path cannot contain Chinese, otherwise it will not start
- After the command window is started, various pop-up windows will flash away, don’t worry about it
- start nginx: for the start command
- nginx -t is the startup status check command
4) Test, access
Normally, when port 80 is not occupied, enter the url: localhost, and the page will display:
5) Configure the code for the two services:
server {
listen 80;
server_name localhost;
location / {
root html/default;
index index.html index.htm;
}
}
#set port
server {
listen 8001;
server_name localhost;
location /{
root html/demo;
index index.html index.htm;
}
}
6) Common commands of nginx in linux version
Help command: nginx -h
Start Nginx server: sudo nginx
View process: ps aux | grep nginx
configuration file path: /usr/local/nginx/conf/nginx.conf
Check configuration file: sudo nginx -t
Specify startup configuration file: sudo nginx -c /usr/local/nginx/conf/nginx.conf
Violent stop service: sudo nginx -s stop
Graceful stop service: sudo nginx -s quit
Reload configuration file: sudo nginx -s reload