NGINX, PHP-FPM boot automatically

Source: Internet
Author: User
Tags fpm

1, nginx shell script put to/etc/init.d/under the name Nginx

#!/bin/SH# # Nginx-This script starts and stops the Nginx Daemon # # Chkconfig:- -  the# Description:nginx is an HTTP (s) server, HTTP (s) reverse # Proxy and IMAP/POP3 Proxy Server # processname:nginx # chkconfig:2345  -  the# Description:nginx Web server# processname:nginx# config:/opt/nginx/conf/nginx.conf# pidfile:/opt/nginx/nginx.pid# SourcefunctionLibrary:/etc/init.d/functions# Source Networking configuration:/etc/sysconfig/Networkif[-f/etc/sysconfig/nginx]; Then. /etc/sysconfig/Nginxfi# Check that networking are up. [ "$NETWORKING"="No"] && exit0Nginx="/usr/local/nginx/sbin/nginx"Prog=$(basename$nginx) Nginx_conf_file="/usr/local/nginx/conf/nginx.conf"[ -f/etc/sysconfig/nginx] &&. /etc/sysconfig/NginxLockfile=/var/lock/subsys/Nginxstart () {[-X $nginx] | | Exit5 [ -F $NGINX _conf_file] | | Exit6 Echo-N $"starting $prog:"Daemon $nginx #-c $NGINX _conf_file retval=$?Echo[$retval-eq0] &&Touch$Lockfilereturn $retval}stop () {Echo-N $"stopping $prog:"Killproc $prog-QUIT retval=$?Echo[$retval-eq0] &&RM-F $Lockfilereturn $retvalKillall-9Nginx}restart () {configtest|| Return $?StopSleep 1start}reload () {configtest|| Return $?Echo-N $"Reloading $prog:"Killproc $nginx-HUP RETVAL=$?Echo}force_reload () {restart}configtest () {$nginx-T #-c $NGINX _conf_file}rh_status () {status $prog}rh_status_q () {rh_status>/dev/NULL 2>&1 } Case " $" inchstart) Rh_status_q&& exit0     $1;; stop) Rh_status_q|| Exit0     $1;; restart) $1;; test) configtest;; Reload) Rh_status_q|| Exit7     $1;; force-reload) force_reload;; status) Rh_status;; Condrestart|try-restart) rh_status_q|| Exit0     ;; *) Echo$"Usage: $ {start|stop|status|restart|condrestart|try-restart|reload|force-reload|test}"Exit2 Esac

2, php-fpm shell script placed under/etc/init.d/name PHP-FPM

#!/bin/bash# PHP-FPM startup script forThe php-fpm # php-FPM version:5.5.0-alpha6# chkconfig:- -  the# description:php-FPM is very good# processname:php-fpm# pidfile:/var/run/php-fpm.pid# config:/usr/local/php/etc/php-fpm.conf Php_command=/usr/local/php/sbin/php-Fomphp_config=/usr/local/php/etc/php-Fpm.confphp_pid=/usr/local/php/var/run/php-Fpm.pidretval=0Prog="PHP-FPM"#startfunctionPhp_fpm_start () {/usr/local/php/sbin/php-FPM} start () {if[ -e $php _pid] Then    Echo "php-fpm already start ..."Exit1    fiPhp_fpm_start} stop () {if[ -e $php _pid] ThenParent_pid=`Cat$php _pid ' All_pid=`PS-ef |grepPHP-FPM |awk '{if ('$parent _pid'= = $ $) {print $}}'`     forPidinch$all _pid Do            Kill$pid Done        Kill$parent _pidfiExit1} restart () {Stop start} # See how we were called. Case " $" inchstart) Start; stop) stop;; restart) stop start;; Status) status $prog RETVAL=$?        ;;*)        Echo$"Usage: $prog {start|stop|restart|status}"Exit1EsacExit $RETVAL

Finally, add two scripts to the system service

# # Add Execute Permissions
chmod A+x/etc/init.d/nginx
chmod a+x/etc/init.d/php-fpm

# # Join the service
Chkconfig--add Nginx
Chkconfig--add PHP-FPM

# # Boot Start
Chkconfig Nginx on
Chkconfig PHP-FPM on

NGINX, PHP-FPM boot automatically

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.