Init Service control script for compiled and installed Nginx

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.