systemd配置nginx

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
User=www
Group=www

[Install]
WantedBy=multi-user.target

 

service文件保存到/lib/systemd/system/nginx.service

重载systemd配置文件
systemctl daemon-reload

systemctl status nginx
systemctl start nginx
systemctl stop nginx
systemctl enable nginx

systemctl reload nginx

 

posted @ 2021-06-29 19:51  TIMLONG  阅读(802)  评论(0编辑  收藏  举报