Using nginx to deploy web applications in windows system

        ​​​​To use Nginx to locally deploy and run web applications on Windows systems, you can follow the steps below:

1. First download nginx, you need to go to the nginx official website:

nginx: download

Download the latest version:

2. Decompress Nginx: Find a disk location, create a new folder (without Chinese name symbols), and decompress the downloaded Nginx compressed file into the directory of your choice. You can do this using any decompression tool such as WinRAR or 7-Zip. :

3. Configure Nginx: In the Nginx directory, find the configuration file named nginx.conf. Open the file with a text editor such as Notepad++ and configure it according to your needs. Here are some common configuration items:

  • server blocks: Within a http block, you can define one or more server blocks, one for each server block Represents a virtual host. You can specify information such as the host name, port number, and root directory of the web application.

  • location blocks: Within each server block, you can use location blocks to define how different URL paths are handled. For example, you can proxy a specific URL path to a backend application or serve static files.

4. Start Nginx: Open Command Prompt (CMD) or PowerShell and navigate to the Nginx directory. Run the following command to start the Nginx server:

        At this time, do not click on the exe file. We need to run it on cmd. Also, if your local colleague has a web application, such as one that occupies port 80, we need to change the http application port 80 of nginx to 8081, for example. Open nginx.conf with Notepad and change 80 to 8081:

Start command:

(1) Reload the configuration file

.\nginx -s reload

(2) Start nginx

start nginx

(3) Check whether the nginx process exists in the task manager

tasklist /fi "imagename eq nginx.exe"

        It may be that there is an error at startup. Check the log. The error.log is the log file in the logs folder in the nginx directory.

As shown below:
 

operation result:

You can replace the index.html in nginx with your packaging file, similar to tomcat deployment, and you can replace and run your own project!

Guess you like

Origin blog.csdn.net/XU441520/article/details/134692471