In the production environment Nginx is compiled installation, but the source package does not provide the Init script
Download the appropriate system script from here: http://wiki.nginx.org/InitScripts, and make simple changes
The revised content is as follows
1#!/bin/Bash2 #3# Nginx-This script starts and stops the Nginx daemon4 #5# Chkconfig:- - the 6 # Description:nginx is an HTTP (s) server, HTTP (s) reverse7# Proxy and imap/POP3 Proxy Server8 # Processname:nginx9# config:/usr/local/nginx/conf/nginx.confTen One# SourcefunctionLibrary. A. /etc/rc.d/init.d/functions - - # Source Networking configuration. the. /etc/sysconfig/Network - - # Check that networking are up. -["$NETWORKING"="No"] && exit0 + -nginx="/usr/local/nginx/sbin/nginx"#nginx启动文件位置 +prog=$ (basename$nginx) A atnginx_conf_file="/usr/local/nginx/conf/nginx.conf"#配置文件 - - - Lockfile=/usr/local/nginx/logs/Nginx #锁文件 - - in start () { -[-X $nginx] | | Exit5 to[-F $NGINX _conf_file] | | Exit6 + Echo-N $"starting $prog:" -Daemon $nginx-C $NGINX _conf_file theRetval=$? * Echo $[$retval-eq0] &&Touch$LockfilePanax Notoginseng return $retval - } the + Stop () { A Echo-N $"stopping $prog:" theKillproc $prog-QUIT +Retval=$? - Echo $[$retval-eq0] &&RM-F $Lockfile $ return $retval - } - the Restart () { -Configtest | | Return $?Wuyi Stop the Sleep 1 - Start Wu } - About Reload () { $Configtest | | Return $? - Echo-N $"Reloading $prog:" -Killproc $nginx-HUP -Retval=$? A Echo + } the - force_reload () { $ Restart the } the the configtest () { the$nginx-T-C $NGINX _conf_file - } in the Rh_status () { the Status $prog About } the the rh_status_q () { theRh_status >/dev/NULL 2>&1 + } - the Case " $" inchBayi start) theRh_status_q && exit0 the$1 - ;; - stop) theRh_status_q | | Exit0 the$1 the ;; theRestart|configtest) -$1 the ;; the Reload) theRh_status_q | | Exit794$1 the ;; theforce-Reload) the Force_reload98 ;; About status) - Rh_status101 ;;102condrestart|try-restart)103Rh_status_q | | Exit0104 ;; the*)106 Echo$"Usage: $ {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"107Exit2108 Esac
Init Service control script for compiled and installed Nginx