nginx 开启不启动
#! /bin/sh# chkconfig: 2345 55 25
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx'
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
# Author: DaoBiDao
# website:http://daobidao.com
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
NGINX=/usr/local/nginx/sbin/$NAME
PROG=$(basename $NGINX)
NGINX_CONF_FILE=/usr/local/nginx/conf/$NAME.conf
lockfile=/var/lock/subsys/$NAME
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|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
阿里云云主机centos5.8 上测试可以开机启动,有需求的小伙伴可以试试
页:
[1]