Nginx CentOS Service boot Setup
 
Create a service file
 
Taking Nginx as an example
 
Vim/lib/systemd/system/nginx.service
 
Insert content in Nginx.service
 
 
  
  
[Unit] 
Description=nginx 
after=network.target 
[service] 
type=forking 
execstart= Services startup command
execreload= Service restart command
execstop= Service stop command
privatetmp=true 
[Install] 
Wantedby=multi-user.target 
 
   
  
[Unit]: Description of the service
Description: Describing services
After: Description of service categories
Settings for running parameters for service services
Type=forking is the form of background running
Execstart the specific Run command for the service
Execreload reboot Command
Execstop to stop command
Privatetmp=true represents a temporary space for a service to be allocated independently
Note: The start, restart, and stop commands for service are all required to use absolute paths
 
Saved in directory with 754 permissions:/lib/systemd/system
 
To set the power-on self boot:
 
Systemctl Enable Nginx.service
 
Related commands
 
function Cnetos7 before CNETOS7
Show all started services Chkconfig--list systemctl list-units--type=service
 
Start a service nginx start Systemctl start Nginx.service or Systemctl start Nginx
 
Stop a service nginx stop Systemctl stop Nginx.service or systemctl stop Nginx
 
Restart a service nginx restart Systemctl Restart Nginx.service or systemctl restart Nginx
 
Enable a service to start automatically chkconfig--level 3 nginx on Systemctl enable Nginx.service or Systemctl enable Nginx
 
Make a service not start automatically chkconfig--level 3 nginx off systemctl disable Nginx.service or systemctl disable Nginx
 
Check Service status Nginx status Systemctl is-active nginx.service (show only if) Activesystemctl status nginx.se Rvice (Service details)
 
Thank you for reading, I hope to help you, thank you for your support for this site!