nginx安装目录/usr/local/nginx
[root@web46 ~]# cd /etc/systemd/system
[root@web46 system]# vim nginx.service
[Unit]
# 描述服务
Description=nginx-The High-performance HTTP Server
# 前置服务
After=network.target remote-fs.target nss-lookup.target
[Service]
# 后台运行的形式
Type=forking
# PID文件的路径
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