Nginx automatic startup script
Last Update:2014-05-29
Source: Internet
Author: User
Save the following script as an nginx file and put it in/etc/init. d/nginx then you can use/etc/init. d/nginxstart command to start nginx/etc/init. d/nginxstop command to stop nginx/etc/init. d/nginxrestart command restart nginx boot automatically start nginx, such... save the following script as an nginx file and put it in/etc/init. d/nginx then you can use/etc/init. d/nginx start command to start nginx/etc/init. d/nginx stop command to stop nginx/etc/init. d/nginx restart command restart nginx boot automatically start nginx, if you need to start the service, save/etc/init. d/nginx file, run the following command: chkconfig -- add ningx chkconfig -- level nginx 2345 On, you can also download #! /Bin/sh # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the nginx web server PATH =/usr/local/sbin: /usr/local/bin:/sbin:/bin:/usr/sbin: /usr/binDESC = "nginx daemon" NAME = nginxDAEMON =/usr/local/nginx/sbin/$ NAMECONFIGFILE =/usr/local/nginx/conf/$ NAME. confPIDFILE =/usr/local/nginx/logs/$ NAME. pidSCRIPTNAME =/etc/init. d/$ NAME set-e [-x "$ DAEMON"] | exit 0 do_start () {$ DAEMON-c $ C ONFIGFILE | echo-n "nginx already running"} do_stop () {kill-INT 'cat $ pidfile' | echo-n "nginx not running"} do_reload () {kill-HUP 'cat $ pidfile' | echo-n "nginx can't reload"} case "$1" in start) echo-n "Starting $ DESC: $ NAME "do_start echo ". "; stop) echo-n" Stopping $ DESC: $ NAME "do_stop echo ". "; reload | graceful) echo-n" Reloading $ DESC configuration... "do_reload echo ". ";; Restart) echo-n "Restarting $ DESC: $ NAME" do_stop do_start echo ". "; *) echo" Usage: $ SCRIPTNAME {start | stop | reload | restart} "> & 2 exit 3; esac exit 0 ------------------- the script content is under the split line, you need to modify the red font -------------------------------------------#! /Bin/sh PATH =/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin: /usr/bin DESC = "nginx daemon" NAME = nginxDAEMON =/usr/local/nginx/sbin/$ NAMECONFIGFILE =/usr/local/nginx/conf/$ NAME. confPIDFILE =/usr/local/nginx/logs/$ NAME. pidSCRIPTNAME =/etc/init. d/$ NAME set-e [-x "$ DAEMON"] | exit 0 do_start () {$ DAEMON-c $ CONFIGFILE | echo-n "nginx already running"} do_stop () {kill-INT 'cat $ pidfile' | echo-n "nginx not running"} do_reload () {kill-HUP 'cat $ pidfile' | echo-n "nginx can't reload"} case "$1" instart) echo-n "Starting $ DESC: $ NAME "do_startecho ". "; stop) echo-n" Stopping $ DESC: $ NAME "do_stopecho ". "; reload | graceful) echo-n" Reloading $ DESC configuration... "do_reloadecho ". "; restart) echo-n" Restarting $ DESC: $ NAME "do_stopdo_startecho ". "; *) echo" Usage: $ SCRIPTNAME {start | stop | reload | restart} "> & 2 exit 3; esac exit 0