nginx 注册Linux 开机启动

nginx 注册Linux 开机启动

前提已经安装好了,nginx (查看之前的文章)

 

cd  /usr/lib/systemd/system/

[root@machine138 keepalived]# cd /usr/lib/systemd/system/
[root@machine138 system]# vi nginx.service

 

 

 创建服务文件nginx.service

[Unit]
Description=nginx - high performance web server 
Documentation=http://nginx.org/en/docs/
After=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 -c /usr/local/nginx/conf/nginx.conf
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

 

 设置开机启动

systemctl enable nginx

 

 重启 reboot

 

 

ok 设置完成

 

posted on 2023-02-20 15:45  hztech  阅读(46)  评论(0编辑  收藏  举报

导航