Nginx self-starting script in Centos

Source: Internet
Author: User

Nginx self-starting script 01 www.2cto.com # Under Centos #! /Bin/bash02 # ckconfig: 345 40 4003NGINX_PATH =/web/container/nginx-1.2.604NGINX_COMMAND = $ NGINX_PATH/sbin/nginx05NGINX_PID = $ NGINX_PATH/logs/nginx. pid06VERSION = 1.2.607CONF = $208 09 start () 10 {11if [-f $ NGINX_PID]; 12then13echo "[Failure] Nginx is starting" 14else15echo "[Success] Starting Nginx $ VERSION" 16 # use the same user to perform operations 17 #/bin/su-nginx- c "$ NGINX_PATH/nginx $ CONF 1>/dev/null 2>/dev/null" 18 $ NGINX_COMMAND $ CONF 1>/dev/null 2>/dev/null19fi20} 21 22 stop () 23 {24 echo $ NGINX_PID25if [-f $ NGINX_PID]; 26then27echo "[Success] Stopping Nginx $ VERSION" 28 $ NGINX_COMMAND-s quit29 #/bin/kill-QUIT $ (eval "/bin/cat $ NGINX_PID ") 30else31echo "[Failure] Stop Failure. nginx isn't starting "32fi33} 34 35 reload () 36 {37if test-f $ NGINX_PID; 38then39echo "[Success] Reloading Nginx $ VERSION" 40 $ NGINX_COMMAND-s reload41else42echo "[Failure] Reload Failure. nginx isn't starting "43fi44} 45 46out () 47 {48if test-f $ NGINX_PID; 49then50echo "[Success] Exiting Nginx $ VERSION" 51 $ NGINX_COMMAND-s stop52 #/bin/kill-9 $ (eval "/bin/cat $ NGINX_PID ") 53else54echo "[Failure] Exiting Failure. nginx isn't starting "55fi56} 57 58 case" $1 "in59start) 60start61; 62 stop) 63stop64 65; 66 restart) 67 68stop69sleep 370start71; 72 exit) 73out74; 75 reload) 76reload77; 78 *) 79 echo $ "Usage: $0 {start | stop | restart | exit | reload}" 80 exit 181 ;; 82esac83exit 0 save the file as nginx, and then enter (assuming in the/web directory) mv/web/nginx/etc/init. d. Press ENTER cd/etc/init. d chkconfig -- add. /nginx press ENTER chkconfig nginx on press enter/sbin/service nginx start and then reboot to see it.
 

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.