Nginx server adds Systemd custom service process analysis

Nginx server adds Systemd custom service process analysis

1. Take nginx as an example

Nginx installed using the yum command

Systemd service files end with .service. For example, if you want to set up nginx for startup, if you use the yum install command to install it, the yum command will automatically create the nginx.service file. Just use the command:

systemcel enable nginx.service //Start automatically at boot

Compile and install using source code

1. Manually create the nginx.service service file. and put it into /lib/systemd/system folder.

The content of nginx.service is as follows:

[Unit]
Description=nginx
After=network.target

[Service]
Type=forking
ExecStart=/data/nginx/sbin/nginx
ExecReload=/data/nginx/sbin/nginx -s reload
ExecStop=/data/nginx/sbin/nginx -s quit
PrivateTmp=true

[Install]
WantedBy=multi-user.target

PS: Note that the above ExecStart/ExecReload/ExecStop must be based on your own

Corresponding key description

Description:Describe the service
After: Describe the service category
[Service] Setting of service operation parameters
Type=forking means background operation
ExecStart is the specific running command of the service
ExecReload is the restart command
ExecStop is the stop command
PrivateTmp=True means to allocate independent temporary space to the service. Note: All start, restart, and stop commands of [Service] require absolute paths.
[Install] Related settings for service installation under the running level can be set to multi-user, that is, the system running level is 3

Save and exit.

2. Set the startup

systemctl enable nginx.service

Other service commands

systemctl start nginx.service (Start nginx service)
systemctl stop nginx.service (Stop nginx service)
systemctl enable nginx.service (set to start automatically at boot)
systemctl disable nginx.service (stop booting automatically)
systemctl status nginx.service (check the current status of the service)
systemctl restart nginx.service (Restart the service)
systemctl list-units --type=service (view all started services)

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to deploy golang project using systemd
  • How to add custom system services to CentOS7 systemd
  • Centos7 startup process and Nginx startup configuration in Systemd
  • In-depth analysis of systemd in centos7
  • How to add custom system services to systemd and set custom startup
  • Docker deployment nginx implementation process graphic and text detailed explanation
  • Nginx access log and error log parameter description
  • Nginx 502 Bad Gateway Error Causes and Solutions

<<:  Summary of Mysql exists usage

>>:  Compatibility with the inline-block property

Recommend

In-depth explanation of the impact of NULL on indexes in MySQL

Preface I have read many blogs and heard many peo...

Two ways to implement text stroke in CSS3 (summary)

question Recently I encountered a requirement to ...

Detailed explanation of Vuex environment

Table of contents Build Vuex environment Summariz...

HTML meta explained

Introduction The meta tag is an auxiliary tag in ...

How to enable JMX monitoring through Tomcat

Build a simulation environment: Operating system:...

Pitfalls and solutions for upgrading MySQL 5.7.23 in CentOS 7

Preface Recently, I found a pitfall in upgrading ...

Installation tutorial of MySQL 5.7 green version under windows2008 64-bit system

Preface This article introduces the installation ...

Introduction to Linux compression and decompression commands

Table of contents Common compression formats: gz ...

Implementation of CSS3 button border animation

First look at the effect: html <a href="#...

Introduction and use of js observer mode

Table of contents I. Definition 2. Usage scenario...

JavaScript function encapsulates random color verification code (complete code)

An n-digit verification code consisting of number...