Required skills for test architects - Nginx installation and deployment

Nginx ("engine x") is a high-performance free open source Web and reverse proxy server developed by Russian programmer Igor Sysoev, and an IMAP/POP3/SMTP proxy server. In the case of high concurrent access, Nginx is a good alternative to Apache server. The official website data shows that the TPS per second is as high as about 50W. This article introduces the deployment and startup of nginx on the windows platform for readers and friends.

01 Download

Download at the official website address of nginx, and its official website address is as follows:

http://nginx.org/
insert image description here

Click the link of the latest version of nginx 1.19.6, and then jump to the following nginx download address for version 1.19.6 under Linux and Windows operating systems
insert image description here

We need to install nginx in the windows environment, so click "nginx/Windows-1.19.6", and then as shown in the figure below, the nginx download progress tab will appear at the bottom of the browser window, and wait for the nginx download to complete.

insert image description here

02 Installation

Unzip the download file nginx-1.19.6.zip. Cut the decompressed file nginx-1.19.6 to a non-system disk.

As shown below, it is the directory structure of nginx, nginx.exe is the startup tool of nginx, the configuration file of nginx is in the conf directory, and the log file is stored in the logs directory.

insert image description here

03 Start

There are many startup methods. You can double-click nginx.exe in the nginx decompression directory to start nginx, and a flashing window appears, which is normal, indicating that the nginx server has been started;

You can also enter the command nginx in the cmd command window, use the command to reach the compressed directory of nginx, and then enter the nginx command, as shown below:
insert image description here

Enter the address in the browser address box:

http://localhost:80

or http://127.0.0.1:80

or http://localhost

or http://127.0.0.1

Then the following information appears in the browser, indicating that nginx was successfully started

insert image description here

04 Configuration

(1) Modify
nginx.conf in the port number conf directory. The default configured port for nginx to listen to is 80. If port 80 is occupied, it can be changed to an unoccupied port.

insert image description here

Notice:

The command to check if port 80 is occupied is: netstat -ano | findstr "80"

When we modify the nginx configuration file nginx.conf, we don't need to close nginx and then restart nginx, just execute the command nginx -s reload to make the changes take effect.

insert image description here

(2) Configure static resources
Create a new static directory under the decompressed nginx directory, and copy and paste a picture resource 1.jpg in this directory:
insert image description here

Then in the nginx.conf configuration file, root modifies the relative path to static, as follows:

insert image description here

Then execute the command nginx -s reload to make the modification take effect, and then enter the access address in the browser address bar: http://localhost/1.jpg

insert image description here

05 stop

insert image description here

If you use the cmd command window to start nginx, closing the cmd window cannot end the nginx process. You can use the following three methods to close nginx:

Enter the nginx command

nginx -s stop (quick stop nginx) or nginx -s quit (complete and orderly stop nginx).

use taskkill

taskkill /f /t /im nginx.exe

End nginx task in task manager

The above are the commonly used steps for downloading, installing, starting, configuring, and stopping in the Windows environment.

Guess you like

Origin blog.csdn.net/Testfan_zhou/article/details/124242824