Mac OS X/CentOS/Ubuntu/Windows multi-system nginx registered as system service

Source: Internet
Author: User
Tags centos

Nginx provides the-s signal Command line parameter for us to operate on it. You can use the-p prefix parameter to specify the startup path to start multiple fully isolated master processes. You can also use-c filename to explicitly specify different configuration files.

Because the prefix paths are generally long, the reload or reopen nginx master process is inconvenient. In this case, can I use OpenResty in OS X? 3. Self-built shortcuts mentioned in shortcuts to simplify these operations.

In general, on the server, we will use the standard services provided by the operating system to simplify these services. Of course, this method is generally only applicable to one nginx master process.

This article describes how to register nginx as a service on multiple operating systems (in fact, there are not so many ).

1. Mac OS X

Refer to using OpenResty in OS X? 2. Configure the OpenResty environment.

2. CentOS

According to a method provided in CentOS Nginx initialization script (for starting, stopping, and viewing the status), I sorted out the code to gist and downloaded nginxd to/etc/init. d and execute the addnginxservice script.

The following code automatically helps you do the above:

Wget -- no-check-certificate https://gist.githubusercontent.com/zrong/9c7dfce8f274ee451188/raw/77eada5f92dd5583838390f26cc9790b00e63137/nginxd
Wget -- no-check-certificate https://gist.githubusercontent.com/zrong/9c7dfce8f274ee451188/raw/a0084d1ae6d5175c913e4593c99d493487d14c75/addnginxservice & source addnginxservice

3. Ubuntu

It is already Ubuntu, and it is naturally apt-get. There is nothing to say about it.

4. Windows

The nginx Windows binary package does not provide the function of registering as a service. The methods officially provided are the same as those provided in Linux. They are all operated using command line parameters. For example, in the following method from the official wiki, enter the nginx folder and start the nginx process:

Cd nginx/
Start nginx.exe

Run the following command to check whether the nginx process is running:

Tasklist/fi "imagename eq nginx.exe"

Disable nginx process:

Nginx.exe-s quit

Nginx is not developed for windows. The function of the windows version is to make it easier for programmers working on windows to use nginx. Therefore, nginx does not seem to need to be a service power. Although Running as a service. Appears in the Possible future enhancements list.

If you must register Nginx as a service in windows, it provides a way to create Nginx as a service in Windows. This is an article written in 2009. I didn't try it on my Windows 8.1, because I used Vagrang directly.

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.