vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
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=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
ExecQuit=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
为了启动Nginx的systemd服务,步骤如下:
- 设置nginx.service文件的权限
chmod 664 /usr/lib/systemd/system/nginx.service
2.开启服务启动时执行
systemctl enable nginx.service
3.启动服务
systemctl start nginx.service
4.查看服务状态
systemctl status nginx.service
5.验证服务
curl -I 127.0.0.1:8080
标签:ubuntu20.04,sbin,service,nginx,systemctl,usr,local
From: https://www.cnblogs.com/khtt/p/17553755.html