Linux under PHP-FPM boot startup settings

Source: Internet
Author: User
Tags fpm


After compiling the installation PHP-FPM, the default is not to turn on automatic startup, and some configuration is required to boot.

Execute VIM/ETC/INIT.D/PHP-FPM The following new content:


#!/bin/sh
#
# Php-fpm-this script starts and stops the PHP-FPM daemin
#
# Chkconfig:-85 15
# PROCESSNAME:PHP-FPM
# config:/usr/local/php/etc/php-fpm.conf

Set-e

#PATH =/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
desc= "PHP-FPM Daemon"
name=php-fpm
daemon=/usr/local/php/sbin/$NAME #这里设成自己的目录
Configfile=/usr/local/php/etc/php-fpm.conf #这里设成自己的目录
pidfile=/var/run/$NAME. PID #这里设成自己的目录
scriptname=/etc/init.d/$NAME #这里设成自己的目录

# If The daemon file is not found, terminate the script.
Test-x $DAEMON | | Exit 0

D_start () {
$DAEMON-y $CONFIGFILE | | Echo-n "Already Running"
}

D_stop () {
Kill-quit ' Cat $PIDFILE ' | | Echo-n "No Running"
}

D_reload () {
KILL-USR2 ' Cat $PIDFILE ' | | Echo-n "Could not reload"
}

Case "$" in
Start
Echo-n "Starting $DESC: $NAME"
D_start
echo "."
;;
Stop
Echo-n "Stopping $DESC: $NAME"
D_stop
echo "."
;;
Reload
Echo-n "Reloading $DESC configuration ..."
D_reload
echo "Reloaded."
;;
Restart)
Echo-n "Restarting $DESC: $NAME"
D_stop
# Sleep for two seconds before starting again,
# This should give the Nginx daemon some time to perform a graceful stop
Sleep 2
D_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload)" >&2
Exit 3
;;
Esac
Exit 0

Add executable permissions


chmod +x/etc/init.d/php-fpm

Add to boot auto start


Chkconfig--add PHP-FPM
Chkconfig PHP-FPM on

After that, the PHP-FPM will start up automatically, and the following command can be used to reboot


Service PHP-FPM Start
Service PHP-FPM Stop
Service PHP-FPM Reload

Another kind of smooth restart PHP-FPM can use KILL-USR2 php-fpm.pid, through the service command is much faster

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.