Nginx Server startup script in Linux

Source: Internet
Author: User
Tags nginx server

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

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.