麒麟系统设置nginx开机启动

1.创建nginx.service文件

vim /lib/systemd/system/nginx.service

文件内容:

[Unit]
Description=nginx service
After=network.target 
   
[Service] 
Type=forking 
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 quit
PrivateTmp=true 
   
[Install] 
WantedBy=multi-user.target

按esc,:wq!保存退出

2.执行开机自启脚本

systemctl enable nginx.service

常用脚本:

systemctl daemon-reload #重载启动文件 
systemctl enable nginx.service #开机启动nginx 
systemctl start nginx.service #启动nginx 
systemctl stop nginx.service #结束nginx 
systemctl restart nginx.service #重启nginx 
systemctl status nginx.service #查看nginx状态

你可能感兴趣的:(nginx,前端,服务器)