CentOS7 Nginx启动脚本
1、创建脚本文件
vim /lib/systemd/system/nginx.service
2、脚本内容
Nginx的安装路径为/usr/local/nginx
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target 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
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
3、相关命令
- 启动:
systemctl start nginx
- 停止:
systemctl stop nginx
- 重启:
systemctl restart nginx