systemctl管理nginx 持续更新

systemctl 管理nginx
  1. 添加nginx.service
[root@localhost data]# cat /usr/lib/systemd/system/nginx.service
# /usr/lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target sshd-keygen.service

[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/sshd
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
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target
  1. 重新加载服务配置
systemctl daemon-reload
  1. 设置开机自动并测试启动
systemctl enable nginx
systemctl restart nginx
[root@localhost data]# netstat -tunlp |grep nginx
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      4080/nginx: master

转载http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-part-two.html

  1. 脚本安装
    脚本地址
wget http://8.210.62.122/nginx/scripts/install_ngix.sh
bash install_ngix.sh
查看状态
systemctl status nginx
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值