Linux in the Nginx server startup script, put this script into the/etc/init.d/directory, to start and close, and with the Chkconfig command to add Nginx to Chkconfig management, set up boot from boot.
The detailed script is as follows:
#!/bin/bash#author wangning#date 2017-7-14#qq 1198143315#email [email protected][ -f /etc/init.d/functions ] && . /etc/init.d/functions#chkconfig: 2345 46 78#description: nginx service manage################ #define variable#### ########################################### #num = ' ps -ef|grep worker|grep -v grep|wc - L ' nginx=/application/nginx/sbin/nginx####################### #start stop restart reload functions######################### #nginx_start () {if [ $num -gt 5 ];then echo "The nginx service has running" exit 1else $nginx &>/dev/null action "Start nginx" /bin/true fi}nginx_stop () {if [ $num -lt 5 ];then echo "The nginx service has stoped " exit 2else $nginx -s stop action "Stop nginx" /bin/truefi}nginx_restart () {$nginx -s stop$ nginxaction "Restart nginx" /bin/true}nginx_reload () {$nginx -s reloadaction " Reload nginx " /bin/true}######################## #nginx manage################################## ######## #case $1 in start) nginx_start ;; stop) nginx_stop ;; restart) nginx_restart ;; reload) nginx_reload ;; *)  &NBsp; echo "Usage:$0 {start|stop|restart|reload}" Esac
This article is from the "Galloping Camel" blog, make sure to keep this source http://wn2100.blog.51cto.com/9915310/1947817
Nginx Server startup script in Linux