将Nginx配置成系统开机启动服务

# 如何将nginx配置成我们的系统服务
# 1.在/usr/lib/systemd/system目录下面配置nginx.service内容
# 如果想要详细了解制作的过程:https://blog.csdn.net/weixin_40596016/article/details/90485038
vim /usr/lib/systemd/system nginx.service
[Unit]
Description=nginx web service
Documentation=http://nginx.org/en/docs/
After=network.targe

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=True

[Install]
wanteBy=default.target

# 2.分配权限
chmod 755 /usr/lib/systemd/system/nginx.service

# 3.systemctl命令
systemctl start nginx
systemctl stop nginx
systemctl restart nginx
systemctl status nginx
systemctl enable nginx  # 开机启动

# 4.将nginx配置到系统环境变量中
# 只需要在/etc/profile文件最后加上vim /etc/profile
export PATH=$PATH:/usr/local/nginx/sbin

 

上一篇:学习linux的菜鸟 shell脚本中的dat,计算器,内置变量的用法


下一篇:ML10 My_Logistic_Regression