FastCGI Process Manager (FPM)

Sommaire

FPM (FastCGI Process Manager) est une implémentation alternative à PHP FastCGI avec quelques fonctionnalités additionnelles particulièrement utiles pour les environnements à haute charge.

Ces fonctionnalités incluent :

  • Gestion avancée des processus avec stop/start doux (graceful) ;

  • Possibilité de démarrer des processus avec différents uid/gid/chroot/environment, écoutant sur différents ports et utilisant différents php.ini (remplace le safe_mode) ;

  • Journalisation stdout et stderr ;

  • Redémarrage d'urgence en cas de destruction accidentelle du cache opcode ;

  • Support de l'upload acccéléré ;

  • "slowlog" - journalisation des scripts (pas juste leurs noms, mais leur backtrace PHP également, utilisant ptrace ou équivalent pour lire le processus distant) qui s'éxecutent de manière anormalement lente ;

  • fastcgi_finish_request() - fonction spéciale pour terminer la requête et vider toutes les données tout en continuant d'exécuter une tâche consommatrice (conversion vidéo par exemple) ;

  • Naissance de processus fils dynamic/static ;

  • Informations sur la SAPI (similaire à mod_status d'Apache) ;

  • Fichier de configuration basé sur php.ini

add a note add a note

User Contributed Notes 4 notes

up
10
joel k
3 years ago
the fpm process supports the USER2 signal, which is used to reload the config file.

kill -USR2 [pid]

should do the trick.
up
6
kokushibyou at gmail dot com
1 year ago
PHP-FPM is FAST - but be wary of using it while your code base is stored on NFS - under average load your NFS server will feel some serious strain. I have yet to find a work around for this bug: https://bugs.php.net/bug.php?id=52312
up
3
robin at robinwinslow dot co dot uk
3 years ago
Init script setup
===

You will probably want to create an init script for your new php-fpm. Fortunately, PHP 5.3.3 provides one for you, which you should copy to your init directory and change permissions:

$ cp <php-5.3.3-source-dir>/sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm
$ chmod 755 /etc/init.d/php-fpm

It requires a certain amount of setup. First of all, make sure your php-fpm.conf file is set up to  create a PID file when php-fpm starts. E.g.:
----
pid = /var/run/php-fpm.pid
----
(also make sure your php-fpm user has permission to create this file).

Now open up your new init script (/etc/init.d/php-fpm) and set the variables at the top to their relevant values. E.g.:
---
prefix=
exec_prefix=
php_fpm_BIN=/sbin/php-fpm
php_fpm_CONF=/etc/php-fpm.conf
php_fpm_PID=/var/run/php-fpm.pid
---

Your init script is now ready. You should now be able to start, stop and reload php-fpm:

$ /etc/init.d/php-fpm start
$ /etc/init.d/php-fpm stop
$ /etc/init.d/php-fpm reload

The one remaining thing you may wish to do is to add your new php-fpm init script to system start-up. E.g. in CentOS:

$ /sbin/chkconfig php-fpm on

===========

Disclaimer: Although I did just do this on my own server about 20 mins ago, everything I've written here is off the top of my head, so it may not be 100% correct. Also, allow for differences in system setup. Some understanding of what you are doing is assumed.
up
-1
dreamcat4 at gmail dot com
5 months ago
Doesn't work? Enable logging!

The php-fpm.log file is a great place to fault-find errors and get to the bottom of a problem. But be sure to enable logging for your specific worker pool. Or you won't see anything!

Example:

To enable error logging for the default [www] worker pool, add this line in the [www] section of your php-fpm.conf:

[www]
catch_workers_output = yes
To Top