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

Two practical ways to enable proxy in React

Two ways to enable proxy React does not have enca...

Mysql 8.0 installation and password reset issues

Mysql 8.0 installation problems and password rese...

The difference between html block-level tags and inline tags

1. Block-level element: refers to the ability to e...

MySQL Server 8.0.13.0 Installation Tutorial with Pictures and Text

Install 8.0.13 based on MySQL 6.1.3. MySQL 8.0.13...

VUE implements token login verification

This article example shares the specific code of ...

Detailed explanation of COLLATION examples in MySQL that you may have overlooked

Preface The string types of MySQL database are CH...

Basic installation tutorial of mysql decompression package

Since I have changed to a new computer, all the e...

Analysis of the method of setting up scheduled tasks in mysql

This article uses an example to describe how to s...

MySQL trigger trigger add, delete, modify and query operation example

This article uses examples to describe the add, d...

React new version life cycle hook function and usage detailed explanation

Compared with the old life cycle Three hooks are ...

Nginx configuration based on multiple domain names, ports, IP virtual hosts

1. Type introduction 1.1 Domain-based virtual hos...