CentOS 7下为Nginx启用进程守护,使用systemctl

1、cd到指定目录

cd /usr/lib/systemd/system

2、创建nginx.service

vi nginx.service

3.输入一下内容,路径为nginx安装路径

[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

其它命令

#重启应用
systemctl restart frps

#停止应用
systemctl stop frps

#查看应用的日志
systemctl status frps

猜你喜欢

转载自www.cnblogs.com/ysmc/p/12107511.html