CentOS 7 Setup Boot service to add custom system services
- Create a service file
- Save Directory
- Set up boot from
- Other commands
1. Create a service file
File path
vim /usr/lib/systemd/system
Service file Content
[Unit]Description=nginx - high performance web serverAfter=network.target remote-fs.target nss-lookup.target[Service]Type=forkingExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confExecReload=/usr/local/nginx/sbin/nginx -s reloadExecStop=/usr/local/nginx/sbin/nginx -s stop[Install]WantedBy=multi-user.target
Document Content Interpretation
[Unit]:服务的说明Description:描述服务After:描述服务类别[Service]服务运行参数的设置Type=forking是后台运行的形式ExecStart为服务的具体运行命令ExecReload为重启命令ExecStop为停止命令PrivateTmp=True表示给服务分配独立的临时空间注意:启动、重启、停止命令全部要求使用绝对路径[Install]服务安装的相关设置,可设置为多用户
2. Save the Directory
Save in Directory with 754 permissions:
/usr/lib/systemd/system
3. Set up boot from boot
Execute under any directory
systemctl enable nginx.service
4. Other commands
Start Nginx Service
start nginx.service
Set up boot from
systemctl enable nginx.service
Stop Boot from booting
systemctl disable nginx.service
View the current status of the service
systemctl status nginx.service
Restart Service
systemctl restart nginx.service
View all services that have been started
list-units --type=service
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the CentOS 7 Setup Boot service, add custom system services, including the CentOS 7 aspects of the content, I hope that the PHP tutorial interested in a friend helpful.