- #!/bin/sh
- # 将脚本保存为/etc/rc.d/init.d/nginxd,便可以使用service命令启动、
停止、重启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
- RETVAL=0
- prog="nginx"
- nginxDir=/usr/local/nginx
- nginxd=$nginxDir/sbin/nginx
- nginxConf=$nginxDir/conf/nginx.conf
- nginxPid=$nginxDir/nginx.pid
- start()
- {
- if [[ -e $nginxPid ]]; then
- echo "$prog already running..."
- exit 1
- else
- echo -n $"Starting $prog:"
- daemon $nginxd -c $nginxConf
- RETVAL=$?
- echo
- [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
- return $RETVAL
- fi
- }
- stop()
- {
- echo -n $"Stopping $prog:"
- killproc $nginxd
- RETVAL=$?
- echo
- [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx $nginxPid
- }
- reload()
- {
- echo -n $"Reloading $prog:"
- killproc $nginxd -HUP
- RETVAL=$?
- echo
- }
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- stop
- start
- ;;
- reload)
- reload
- ;;
- status)
- status $prog
- RETVAL=$?
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|status}"
- RETVAL=1
- esac
- exit $RETVAL
nginx启动脚本
原创
©著作权归作者所有:来自51CTO博客作者outhink的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:windows 远程连接端口修改
下一篇:nginx日志自动切割
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章