Ext.: http://blog.csdn.net/field_yang/article/details/52401994
This article mainly describes: How to configure PHP-FPM, common error resolution and PHP-FPM startup, shutdown and restart.
Nginx in the LNMP environment does not support PHP and requires the fastcgi plugin to handle PHP requests. 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 later only need to use –ENABLE-FPM to load the module when compiling the installation, no additional installation.
[Email protected] 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 configuration file 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 copied to/ usr/local/php/etc/or/usr/local/etc/and rename to php-fpm.conf
①
[Email protected] etc]# cd/usr/local/php/etc/
[[email protected] etc]# ls
Pear.conf Php-fpm.conf.default
[email protected] etc]# cp/usr/local/php/etc/php-fpm.conf/usr/local/etc/php-fpm.conf
Start fpm with/USR/LOCAL/PHP/SBIN/PHP-FPM
[Email protected] etc]#/USR/LOCAL/PHP/SBIN/PHP-FPM
Ii
[email protected] etc] #cp php-fpm.conf.defaultphp-fpm.conf
[Email protected] etc]#/USR/LOCAL/PHP/SBIN/PHP-FPM
At this point the PHP-FPM configuration is complete, and since FPM is a layer of application placed between PHP and Nginx, it is configured to boot as a service.
The following configuration php-fpm starts as a service
[Email protected] etc]# cd/usr/local/php-5.6.25/
[Email protected] php-5.6.25]# CP./SAPI/FPM/INIT.D.PHP-FPM/ETC/INIT.D/PHP-FPM
[Email protected] 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
[Email protected] php-5.6.25]# chmod a+x/etc/init.d/php-fpm
[Email protected] 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
[Email protected] 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
[Email protected] php-5.6.25]# NETSTAT-TUNLP |grep9000
TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 4928/php-fpm
[[email protected] etc]#/ETC/INIT.D/PHP-FPM stop
Gracefully shutting down php-fpm warning,no pid file found-php-fpm are not running?
Closed PHP-FPM Service found error, lack of PID file, solution for editing configuration file, enable PID file
[Email protected] etc]# vim php-fpm.conf
PID = Run/php-fpm.pid
[Email protected] 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
[[email protected] etc]#/ETC/INIT.D/PHP-FPM stop
Gracefully shutting down php-fpm warning,no pid file found-php-fpm are not running?
Try to close the service again error, manually set up the Php-fpm.pid file can be
[Email protected] etc]# cd/usr/local/php/var/run/
[Email protected] run]# vim Php-fpm.pid
[[email protected] run]# ls
Php-fpm.pid
[[Email protected] run]# service PHP-FPM stop
Gracefully shutting down php-fpm. Done
[[Email protected] run]# service PHP-FPM start
Starting php-fpm Done
[Email protected] run]# NETSTAT-TUNLP |GREP 9000
TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3008/php-fpm
[Email protected] run]# kill-int ' cat/usr/local/php/var/run/php-fpm.pid '
[Email protected] run]# NETSTAT-TUNLP |GREP 9000
[[email protected] run]#/etc/init.d/php-fpm start
STARTINGPHP-FPM Done
Add the service to the Chkconfig list, set the boot up
[Email protected] run]# chkconfig--add php-fpm
[Email protected] run]# chkconfig php-fpm on
At this point, the PHP-FPM configuration is complete, the following provides two kinds of control methods
①PHP-FPM using signal control:
INT, term immediately terminates
QUIT Smooth Termination
USR1 reopen log file
USR2 smoothly overloads all worker processes and reloads the configuration and binary modules
Start
[Email protected] run]#/USR/LOCAL/PHP/SBIN/PHP-FPM
Shut down:
[Email protected] run]# kill-int ' cat/usr/local/php/var/run/php-fpm.pid '
Restart:
[Email protected] run]# KILL-USR2 ' cat/usr/local/php/var/run/php-fpm.pid '
Ii
Service Mode control
Usage:/etc/init.d/php-fpm{start|stop|force-quit|restart|reload|status}
[[Email protected] run]# service PHP-FPM start
Starting php-fpm Done
[[Email protected] run]# service PHP-FPM stop
Gracefully shutting down php-fpm. Done
[Email protected] run]#/etc/init.d/php-fpm restart
Gracefully shutting down php-fpm. Done
Starting php-fpm Done
[Email protected] run]#
Configuration, startup, shutdown, and restart of php-fpm in PHP5.6