Configuration, startup, shutdown, and restart of php-fpm in PHP5.6

Source: Internet
Author: User
Tags configuration php fpm

This article mainly describes how to configure PHP-FPM, common error resolution and PHP-FPM startup, shutdown, and restart.

The Nginx in the LNMP environment does not support PHP and requires the FASTCGI plug-in to process requests for PHP. and PHP needs to php-fpm This component to provide this functionality. Prior to php5.3.3 version php-fpm is in the form of a patch package, and php5.3.3 can only use –ENABLE-FPM to load the module at the time of compiling the installation, without installing it separately.

[root@localhost php-5.6.25]#/usr/local/php/sbin/php-fpm

[29-aug-2016 17:36:05] error:failed toopen configuration file '/usr/local/php/etc/php-fpm.conf ': No such file Ordirectory (2)

[29-aug-2016 17:36:05] error:failed toload configuration file '/usr/local/php/etc/php-fpm.conf '

[29-aug-2016 17:36:05] Error:fpminitialization failed

Startup PHP-FPM found a lack of configuration files/usr/local/php/etc/php-fpm.conf

At this point, just copy the PHP-FPM profile in the installation of PHP configuration files provided by the template/usr/local/php/etc/php-fpm.conf.default to the appropriate directory, there are two ways, you can provide a configuration file, that is, the last class copy to/ usr/local/php/etc/or/usr/local/etc/rename to php-fpm.conf

[root@localhost etc]# cd/usr/local/php/etc/

[root@localhost etc]# ls

Pear.conf Php-fpm.conf.default

[root@localhost etc]# cp/usr/local/php/etc/php-fpm.conf/usr/local/etc/php-fpm.conf

Use/USR/LOCAL/PHP/SBIN/PHP-FPM to start FPM

[root@localhost etc]#/usr/local/php/sbin/php-fpm

Ii

[root@localhost etc] #cp php-fpm.conf.defaultphp-fpm.conf

[root@localhost etc]#/usr/local/php/sbin/php-fpm

 

This PHP-FPM configuration is complete, since the FPM is placed between PHP and Nginx application, so configure the service to boot.

The following configuration php-fpm starts in service form

[root@localhost etc]# cd/usr/local/php-5.6.25/

[root@localhost php-5.6.25]# cp./sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm

[root@localhost php-5.6.25]# ll/etc/init.d/php-fpm

-rw-r--r--1 root root 2354 August 3115:54/etc/init.d/php-fpm

[root@localhost php-5.6.25]# chmod a+x/etc/init.d/php-fpm

[root@localhost php-5.6.25]# ll/etc/init.d/php-fpm

-rwxr-xr-x 1 root root 2354 August 3115:54/etc/init.d/php-fpm

[Root@localhost php-5.6.25]#/etc/init.d/php-fpmstart

Starting PHP-FPM [31-aug-2016 15:56:00]error:unable to bind listening socket for address ' 127.0.0.1:9000 ': Addressalready In use (98)

[31-aug-2016 15:56:00] Error:fpminitialization failed

Failed

[Root@localhost php-5.6.25]# NETSTAT-TUNLP |grep9000

TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 4928/php-fpm

[root@localhost etc]#/etc/init.d/php-fpm Stop

Gracefully shutting down PHP-FPM warning,no pid file found-php-fpm are not running?

When the PHP-FPM service is turned off, an error is found, the lack of PID files, the solution is to edit the configuration file, enable the PID file

[root@localhost etc]# vim php-fpm.conf

pid = Run/php-fpm.pid

[Root@localhost etc]# kill-int ' cat/usr/local/php/var/run/php-fpm.pid '

Cat:/usr/local/php/var/run/php-fpm.pid: No file or directory

[Root@localhost etc]#/etc/init.d/php-fpm Stop

Gracefully shutting down PHP-FPM warning,no pid file found-php-fpm are not running?

If you try to shut down the service again, create the Php-fpm.pid file manually

[root@localhost etc]# cd/usr/local/php/var/run/

[root@localhost run]# vim Php-fpm.pid

[Root@localhost run]# ls

Php-fpm.pid

[root@localhost run]# service php-fpm Stop

Gracefully shutting down php-fpm. Done

[root@localhost run]# service php-fpm start

Starting php-fpm Done

[Root@localhost run]# NETSTAT-TUNLP |grep 9000

TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3008/php-fpm

[root@localhost run]# kill-int ' cat/usr/local/php/var/run/php-fpm.pid '

[root@localhost run]# netstat-tunlp |grep 9000

[Root@localhost run]#/etc/init.d/php-fpm start

STARTINGPHP-FPM Done

Add service to Chkconfig list, set boot up

[root@localhost run]# chkconfig--add php-fpm

[root@localhost run]# chkconfig php-fpm on

 

now that the PHP-FPM configuration is complete, there are two ways to control

①PHP-FPM uses signal control:

INT, TERM immediately terminated

QUIT Smooth Termination

USR1 Reopen the log file

USR2 Smooth overload of all worker processes and reload configuration and binary modules

Start

[Root@localhost run]#/USR/LOCAL/PHP/SBIN/PHP-FPM

Shut down:

[Root@localhost run]# kill-int ' cat/usr/local/php/var/run/php-fpm.pid '

Reboot:

[Root@localhost run]# kill-usr2 ' cat/usr/local/php/var/run/php-fpm.pid '

Service Mode Control

Usage:/etc/init.d/php-fpm{start|stop|force-quit|restart|reload|status}

[root@localhost run]# service php-fpm start

Starting php-fpm Done

[root@localhost run]# service php-fpm Stop

Gracefully shutting down php-fpm. Done

[root@localhost run]#/etc/init.d/php-fpm Restart

Gracefully shutting down php-fpm. Done

Starting php-fpm Done

[Root@localhost run]#

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.