centos7.6 配置nginx自启动

配置systemctl自启动

# cd /lib/systemd/system/
# vim nginx.service
[Unit]
Description=nginx 
After=network.target 
   
[Service] 
Type=forking 
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx quit
PrivateTmp=true 
   
[Install] 
WantedBy=multi-user.target

QUIT:从容关闭
nginx -s reload : 热重启
退出并保存文件,执行systemctl enable nginx.service使nginx开机启动
启动方法:
systemctl start nginx.service 启动nginx
systemctl stop nginx.service 结束nginx
systemctl restart nginx.service 重启nginx

你可能感兴趣的:(centos7.6 配置nginx自启动)