nginx centos service startup settings

Create a service file

Take nginx as an example

vim /lib/systemd/system/nginx.service

Insert the following in nginx.service

execstart=Service start command
execreload=service restart command
execstop=Service stop command

[unit]:Description of the service

description:description service

after:describe the service category

[service] Setting of service operation parameters

type=forking is the form that runs in the background

execstart is the specific running command for the service

execreload is the restart command

execstop is a stop command

privatetmp=true means to allocate independent temporary space to the service

Note:The [service] start, restart, and stop commands all require absolute paths.

Save in the directory with 754 permissions:/lib/systemd/system

Set the auto-start after power on:

systemctl enable nginx.service

Related commands

Function cnetos7 before cnetos7

Show all started services chkconfig --list systemctl list-units --type=service

Start a service service nginx start systemctl start nginx.service or systemctl start nginx

Stop a service service nginx stop systemctl stop nginx.service or systemctl stop nginx

Restart a service service nginx restart systemctl restart nginx.service or systemctl restart nginx

Chchconfig --level 3 nginx on systemctl enable nginx.service or systemctl enable nginx

Prevent a service from starting automatically chkconfig --level 3 nginx off systemctl disable nginx.service or systemctl disable nginx

Check service status service nginx status systemctl is-active nginx.service (show only if it is active)

  • Previous Android custom soft keyboard design and implementation code
  • Next Android Drawerlayout sidebar event delivery problem solution