nginx启动脚本

声明:

脚本的路径

[root@server5 system]# pwd
/etc/systemd/system

 

脚本:

[root@server5 system]# vim nginx.service
[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

此时nginx已经可以用systemctl 命令修改查看状态了!!


[root@server5 system]# systemctl status nginx
● nginx.service - The NGINX HTTP and reverse proxy server
   Loaded: loaded (/etc/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: inactive (
dead)
[root@server5 system]# systemctl start nginx
[root@server5 system]# systemctl status nginx
● nginx.service - The NGINX HTTP and reverse proxy server
   Loaded: loaded (/etc/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: active (
running) since Sat 2019-03-30 23:26:34 CST; 13s ago
  Process: 5108 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 5107 ExecStartPre=/usr/local/nginx/sbin/nginx -t (code=exited, status=0/SUCCESS)
 Main PID: 5112 (nginx)
   CGroup: /system.slice/nginx.service
           ├─5112 nginx: master process /usr/local/nginx/sbin/nginx
           └─5113 nginx: worker process

Mar 30 23:26:34 server5 systemd[1]: Starting The NGINX HTTP and reverse proxy ser.....
Mar 30 23:26:34 server5 nginx[5107]: nginx: the configuration file /usr/local/ngi...ok
Mar 30 23:26:34 server5 nginx[5107]: nginx: configuration file /usr/local/nginx/c...ul
Mar 30 23:26:34 server5 systemd[1]: Failed to read PID from file /usr/local/nginx...nt
Mar 30 23:26:34 server5 systemd[1]: Started The NGINX HTTP and reverse proxy server.
Hint: Some lines were ellipsized, use -l to show in full.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值