Nginx如何实现重启脚本


这篇文章主要为大家展示了“Nginx如何实现重启脚本”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“Nginx如何实现重启脚本”这篇文章吧。vi /etc/init.d/nginx然后输入如下内容,你将能使用service nginx start
service nginx stop
service nginx restart
service nginx reload这里说明需要说明一下,
# chkconfig:# description:
脚本中这两句注释一定要的,表明是chkconfig支持的格式。不然会有类似下面的提示:
service nginx does not support chkconfig增加后记得要赋予脚本权限chmod 755 nginxchmod +x nginx[@more@]#!/bin/sh
#
# nginx – this script starts and stops the nginx daemin
#
# chkconfig: – 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ “$NETWORKING” = “no” ] && exit 0

nginx=”/usr/local/nginx/sbin/nginx”
prog=$(basename $nginx)

NGINX_CONF_FILE=”/usr/local/nginx/conf/nginx.conf”

lockfile=/var/lock/subsys/nginx

start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $”Starting $prog: “
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}

stop() {
echo -n $”Stopping $prog: “
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}

restart() {
configtest || return $?
stop
start
}

reload() {
configtest || return $?
echo -n $”Reloading $prog: “
killproc $nginx -HUP
RETVAL=$?
echo
}

force_reload() {
restart
}

configtest() {
$nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
status $prog
}

rh_status_q() {
rh_status >/dev/null 2>&1
}

case “$1” in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $”Usage: $0 {start|stop|status|restart|cond免费云主机域名restart|try-restart|reload|force-reload|configtest}”
exit 2
esac以上是“Nginx如何实现重启脚本”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注云编程开发博客行业资讯频道!

相关推荐: 交换机的VACL测试

一.测试拓扑:R1————SW1——————(MAC:2.2.2)R2 | R3R1,R2,R3都在VLAN11中,R1连接SW1的接口手工指定mac地址为1.1.1,R2连接SW1的接口手工指定mac地址为2.2.2;…

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

(0)
打赏 微信扫一扫 微信扫一扫
上一篇 02/03 11:47
下一篇 02/03 11:47