PHP-FPM How to service startup scripts PHP instance

Source: Internet
Author: User
This article mainly introduces the PHP-FPM service startup script method, very good, with reference value, the need for friends can refer to the following

This is my own use, no problem, there are three paths need to modify their own discretion.

Create a self-boot file first:/etc/init.d/php-fpm

The contents are as follows:

#! /bin/sh### BEGIN INIT info# provides:php-fpm# required-start: $remote _fs $network # required-stop: $remote _fs $NETW ork# default-start:2 3 4 AA default-stop:0 1 6# short-description:starts php-fpm# description:starts the PHP Fa stcgi Process Manager daemon### END INIT infoprefix=/usr/local/phpexec_prefix=${prefix}php_fpm_bin=${exec_prefix}/ Sbin/php-fpmphp_fpm_conf=${prefix}/etc/php-fpm.confphp_fpm_pid=${prefix}/var/run/php-fpm.pidphp_opts= "-- Fpm-config $php _fpm_conf--pid $php _fpm_pid "Wait_for_pid () {try=0 while Test $try-lt; Eated ') if [-F "$"];      Then try= "Break fi;; ' Removed ') if [!-F "$"];    Then try= "Break fi;;    Esac Echo-n. try= ' expr $try + 1 ' sleep 1 done}case "in Start" echo-n "Starting php-fpm" $php _fpm_bin--daemonize $php _ opts if ["$?"! = 0]; Then echo "Failed" Exit 1 fi wait_for_pid created $php _fpM_pid if [-N "$try"];  Then echo "Failed" Exit 1 else echo ' done ' fi;; Stop) echo-n "Gracefully shutting down php-fpm" if [! -R $php _fpm_pid];      Then echo "Warning, no PID file found-php-fpm are not running?" Exit 1 fi kill-quit ' cat $php _fpm_pid ' wait_for_pid removed $php _fpm_pid if [-N ' $try]; Then echo "failed.  Use Force-quit "Exit 1 else echo" done "FI;; status) if [!-R $php _fpm_pid]; Then echo "PHP-FPM is stopped" Exit 0 fi pid= ' cat $php _fpm_pid ' if ps-p $PID | Grep-q $PID;  Then echo "PHP-FPM (PID $PID) is running ..." Else echo "php-fpm dead but PID file exists" FI;; Force-quit) echo-n "terminating php-fpm" if [! -R $php _fpm_pid];      Then echo "Warning, no PID file found-php-fpm are not running?" Exit 1 fi kill-term ' cat $php _fpm_pid ' wait_for_pid removed $php _fpm_pid if [-N ' $try]; Then echo "FaileD "Exit 1 else echo" done "FI;;  Restart) $ stop $ start; Reload) echo-n "Reload service php-fpm" if [! -R $php _fpm_pid];      Then echo "Warning, no PID file found-php-fpm are not running?"  Exit 1 fi kill-usr2 ' cat $php _fpm_pid ' echo ' done ';; *) echo "Usage: $ Start|stop|force-quit|restart|reload|status}" exit 1;; Esac

Configuring the PHP-FPM Service

# Set permissions chmod 755/etc/init.d/php-fpm# php-fpm join service chkconfig--add php-fpm# php-fpm level 234 set to start Chkconfig php-fpm on# View php-f PM Service Current configuration chkconfig--list php-fpmphp-fpm     0:off  1:off  2:on  3:on  4:on 5:on 6:off

PHP-FPM How to use

# Start Service php-fpm start# shutdown Service php-fpm stop# Restart service php-fpm restart# reload service php-fpm reload# Check Profile Service Php-f PM Configtest

Script description

# Source function library. . /etc/rc.d/init.d/functions # Source Networking configuration. . /etc/sysconfig/network

The above line of code someone would question what they do, '. ' is the source similar to the program in the include and require, the functions inside the method is all poured into this side, this procedure can be used, for example, this side of the daemon, status. The network in the second line is actually just a few lines, as follows

networking=yeshostname=e10162

Assign them as variables to determine whether the network card is started, if your nginx does not walk the network card, in fact, this paragraph can be removed.

/etc/init.d/php-fpm

Summarize

The above is a small series to introduce you to the PHP-FPM service startup script method, I hope that we have some help, if you have any questions please give me a message, small series will promptly reply to everyone. Thank you very much for the support of PHP Chinese network!

Articles you may be interested in:

PHP Four sorting algorithm implementation and efficiency analysis _php tips

PHP tips for frequently used methods to get file extensions

PHP uses curl to implement the demo login and fetch data function sample PHP tips

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.