码迷,mamicode.com
首页 > 其他好文 > 详细

Nginx 启动脚本

时间:2015-05-17 02:09:29      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:nginx

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# this script create it by jackbillow at 2007.10.15.
# it is v.0.0.2 version.
# if you find any errors on this scripts,please contact jackbillow.
# and send mail to jackbillow at gmail dot com.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
# processname: nginx
nginxd=/usr/sbin/nginx
nginx_config=/etc/nginx/nginx.conf
nginx_pid=/var/run/nginx/nginx.pid  
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions

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

# Check that networking is up.

[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0

# Start nginx daemons functions.

start() {
if [ -e $nginx_pid ];then
echo "nginx already running...."
exit 1
fi
echo -n $"Starting $prog: "
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch $nginx_pid
return $RETVAL
 
}

# Stop nginx daemons functions.

stop() {
echo -n $"Stopping $prog: "
killproc $nginxd

RETVAL=$?
echo

[ $RETVAL = 0 ] && rm -f $nginx_pid

}

# reload nginx service functions.

reload() {
echo -n $"Reloading $prog: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
RETVAL=$?
echo
}

# See how we were called.

case "$1" in

start)
start
;;

stop)

stop


;;

 

reload)

reload


;;

restart)

stop

start

;;

status)

status $prog

RETVAL=$?
;;

*)

echo $"Usage: $prog {start|stop|restart|reload|status|help}"


exit 1

esac

exit $RETVAL  


################################
把以上内容复制到/etc/init.d/nginx 中然后分配执行权限 chmod +x nginx
开机自启动 chkconfig --add nginx
然后就可以service nginx restart/start/stop/reload

本文出自 “咚咚的博客” 博客,转载请与作者联系!

Nginx 启动脚本

标签:nginx

原文地址:http://weadyweady.blog.51cto.com/3012956/1651999

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!