- 创建服务:/usr/lib/systemd/system/openresty.service
[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile= /usr/local/openresty/nginx/logs/nginx.pid
ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart= /usr/local/openresty/nginx/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload= /usr/local/openresty/nginx/sbin/nginx -s reload -c /etc/nginx/nginx.conf
ExecStop= /usr/local/openresty/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
- 启用服务:systemctl enable openresty
- 更新服务:systemctl daemon-reload
- 快乐使用:service openresty start/status/reload/stop