Centos7 Nginx 开机启动

Centos 系统服务脚本目录:

用户(user)

用户登录后才能运行的程序,存在用户(user)

/usr/lib/systemd/ 

系统(system)

如需要开机没有登陆情况下就能运行的程序,存在系统服务(system)里

/lib/systemd/system/ 

服务以.service结尾。

vim /lib/systemd/system/nginx.service 
 
[Unit]
 
Description=nginx
 
After=network.target
 
[Service]
 
Type=forking
 
ExecStart=/usr/local/nginx/sbin/nginx
 
ExecReload=/usr/local/nginx/sbin/nginx -s reload
 
ExecStop=/usr/local/nginx/sbin/nginx -s stop
 
PrivateTmp=true
 
 
 
[Install]
 
WantedBy=multi-user.target
 

设置开机启动

systemctl enable nginx.service 

猜你喜欢

转载自www.cnblogs.com/pcyy/p/9650292.html