nginx服务启动脚本

nginx服务启动脚本

  1. 创建脚本
[root@jun init.d]# cat nginx 
#!/bin/bash
# chkconfig: 2345 20  80
# description: aassddf

case $1 in 
	'stop'|'STOP')
  	  /usr/local/nginx/sbin/nginx -s stop
    ;;
	'start'|'START')
  	  /usr/local/nginx/sbin/nginx
    ;; 
	'restart'|'RESTART')
  	  /usr/local/nginx/sbin/nginx -s stop
  	  /usr/local/nginx/sbin/nginx 
    ;;
	'reload'|'RELOAD')
  	  /usr/local/nginx/nginx -s reload
    ;;
    *)

	echo 'Usage:service nginx stop|restart|start|reload'
esac
	
[root@jun init.d]# 

  1. 把脚本cp到/etc/init.d/目录下
[root@jun ~]# mv nginx.sh /etc/init.d/nginx

  1. 给脚本执行权限
[root@jun init.d]# chmod +x nginx 
[root@jun ~]# ll /etc/init.d/nginx -d
-rwxr-xr-x. 1 root root 434 2月  28 19:00 /etc/init.d/nginx

5.用脚本启动服务

[root@jun ~]# service nginx start
[root@jun ~]# ss -antl
State       Recv-Q Send-Q      Local Address:Port                     Peer Address:Port              
LISTEN      0      128                     *:80                                  *:*                  
LISTEN      0      128                     *:22                                  *:*                  
LISTEN      0      128                     *:10050                               *:*                  
LISTEN      0      128                     *:10051                               *:*                  
LISTEN      0      128             127.0.0.1:9000                                *:*                  
LISTEN      0      128                    :::22                                 :::*                  
LISTEN      0      80                     :::3306                               :::*                  
[root@jun ~]# 

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值