Nginx automatic startup script

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
Related Article

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.