Nginx for Windows: Enable nginx to run as a service (parent correction)

Source: Internet
Author: User

If nginx is installed in Windows, it is found that it is not running as a service, that is, when the user logs out,Program
Will terminate. Therefore, nginx must be run as a service.
Suppose nginx is installed under c: \ nginx:

1. download the software service registration tool srvany.exe and instsrv.exe, which are stored in the C: \ nginx \ directory.
Http://wesoho.com/soft/down/srvany.rar

2. Install the nginx service, switch the command line to c: \ nginx \, and execute the following command
Instsrv nginx c: \ nginx \ srvany.exeNo error occurred while initializing srvany.exe

3. Under c: \ nginx \, edit an nginx. reg file (In this step, I encountered a problem and the import failed.)
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ nginx \ Parameters]
"Application" = "C: \ nginx \ nginx.exe"
"Appparameters" = ""
"Appdirectory" = "C: \ nginx \\"
 

5. Associate services with programs and execute commands
Regedit/s nginx. Reg

Solution to the above execution failure: RunRegeditOpen the registry and add it directly under [HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ nginxParametersAnd then manually create the registry values of the three strings.Application appparameters appdirectory

6. Edit the startup nginx script start-nginx.bat (close the script without changing) to run the program as a service
@ Echo off
Net stop nginx
Net start nginx
Exit

After the above steps, the nginx service is successfully started. In addition, a graphical interface tool srvinstw. EXE is added to the service.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.