nginx启动脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx启动脚本相关的知识,希望对你有一定的参考价值。
#!/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/nginx.pid
# Source function library.
source /etc/init.d/functions
nginx="/usr/local/nginx/sbin/nginx"
name=`basename $nginx`
conf="/usr/local/nginx/conf/nginx.conf"
pid_file="/usr/local/nginx/nginx.pid"
pid=`pgrep nginx|head -1`
status() {
if [ -f $pid_file ];then
echo "$name 正在运行...."
else
echo "$name 已经停止...."
fi
}
start() {
if [ `netstat -ntlp|grep nginx|wc -l` -lt 1 ];then
$nginx
echo "启动 $name 成功...."
else
echo "$name 正在运行...."
fi
}
stop() {
if [ `netstat -ntlp|grep nginx|wc -l` -ge 1 ];then
kill $pid
echo "停止 $name 成功...."
else
echo "$name 已经停止...."
fi
}
case $1 in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
reload)
$nginx -s reload
;;
configtest)
$nginx -t -c $conf
;;
*)
echo "Uesr (start|stop|status|restart|reload|configtest)"
;;
esac
以上是关于nginx启动脚本的主要内容,如果未能解决你的问题,请参考以下文章