& Nbsp; dedicated wait 1. write a script named nginx #! /Bin/sh # nginx-thisscriptstartsandstopsthenginxdaemon # chkconfig:-8515 # description: NginxisanHTTP (S) server, HTTP (S) reverse # proxyandIMAP/
Dedicated waiting
1. write a script named nginx
#! /Bin/sh
#
# Nginx-this script starts and stops the nginx daemon
#
# Chkconfig:-85 15
# Description: Nginx is an HTTP (S) server, HTTP (S) reverse
# Proxy and IMAP/POP3 proxy server
# Processname: nginx
# Config:/etc/nginx. conf
# Config:/etc/sysconfig/nginx
# Pidfile:/var/run/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"
[-F/etc/sysconfig/nginx] &./etc/sysconfig/nginx
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
Killall-9 nginx
}
Restart (){
Configtest | return $?
Stop
Sleep 1
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
2. add chkconfig
[Root @ example ~] # Cp nginx/etc/init. d/
[Root @ example ~] # Chmod 755/etc/init. d/nginx
[Root @ example ~] # Chkconfig -- add nginx
3. start, stop, and restart nginx
[Root @ example ~] # Service nginx start
[Root @ example ~] # Service nginx stop
[Root @ example ~] # Service nginx reload