2019-03-27 CentOS7 Tengine 设置系统自动启动

时间:2022-06-19
本文章向大家介绍2019-03-27 CentOS7 Tengine 设置系统自动启动,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

、设置为系统服务

1:系统用户登录系统后启动的服务 的目录

/usr/lib/systemd/system

2:如需要开机没有登陆情况下就能运行的程序在系统目录内

/lib/systemd/system

3:我希望系统开机就启动目录,所以我把文件放在系统目录内。

创建文件

vim /sur/lib/systemd/system/nginx.service 
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
 
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
 
[Install]
WantedBy=multi-user.target

4、修改文件权限

chmod 745 nginx.service 

5、设置为开机启动

systemctl enable nginx.service

作者:温故而知新666 来源:CSDN 原文:https://blog.csdn.net/nimasike/article/details/51889171 版权声明:本文为博主原创文章,转载请附上博文链接!