1. Added the shell script vi/etc/rc. d/init. d/nginx.
The code is as follows: |
Copy code |
#! /Bin/bash # Chkconfig: 35 85 15 # Description: Nginx is an HTTP (S) server, HTTP (S) reverse Set-e PATH =/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC = "nginx daemon" NAME = nginx DAEMON =/usr/local/nginx/sbin/$ NAME SCRIPTNAME =/etc/init. d/$ NAME Test-x $ DAEMON | exit 0 D_start (){ $ DAEMON | echo-n "already running" } D_stop (){ $ DAEMON-s quit | echo-n "not running" } D_reload (){ $ DAEMON-s reload | echo-n "counld not reload" } Case "$1" in Start) Echo-n "Starting $ DESC: $ NAME" D_start Echo "." ;; Stop) Echo-n "Stopping $ DESC: $ NAME" D_stop Echo "." ;; Reload) Echo-n "Reloading $ DESC configuration ..." D_reload Echo "reloaded ." ;; Restart) Echo-n "Restarting $ DESC: $ NAME" D_stop Sleep 2 D_start Echo "." ;; *) Echo "Usage: $ SCRIPTNAME {start | stop | restart | reload}"> & 2 Exit 3 ;; Esac Exit 0 |
2. Just add shell to the system service.
The code is as follows: |
Copy code |
Chmod + x/etc/rc. d/init. d/nginx (set executable permissions) Chkconfig -- add nginx (add system service) |