- Ubuntu server
Install PHP.
sudo aptitude install php5-fpm
Optionally add this packages.
hp5-idn
php5-curl
php5-gd p
php5-imagick
php5-imap
php5-mcrypt
php5-memcache
php5-ming
php5-mysql
php5-ps
php5-pspell
php5-recode
php5-snmp
php5-sqlite
php5-tidy
php5-xmlrpc
php5-xsl
php-pear
Edit the default pool config file.
sudo vi /etc/php5/fpm/pool.d/www.conf
Comment out these lines as we split them into different configuration files.
;listen = 127.0.0.1:9000
;pm.max_children = 10
;pm.start_servers = 4
;pm.min_spare_servers = 2
;pm.max_spare_servers = 6
Now create the following configuration files in the /etc/php5/fpm/pool.d/
folder.
ping.conf
Health check for php-fpm process. Uses special URL that will simply return "pong".
[www]
ping.path = /ping
processes.conf
Defines exactly how many processes php-fpm is allowed to spawn. Update these settings based on your requirements.
[www]
; at any time, there can be no more than 5 child processes
; if you know how much memory each process consumes regularly
; and how much free memory you have on your system, this is how
; you set a "hard limit" on the amount of memory php-fpm will be able to consume
pm.max_children = 5
; when php-fpm first starts, how many processes should
; it immediately generate to handle requests?
; when you restart php-fpm, there may be an influx of requests.
; spawning a new process can take time (albeit very small), so we want
; to go ahead and have this many ready to go
pm.start_servers = 2
; if there are no requests currently, how many spare
; processes should we always make sure to keep around?
; again, there is a delay in spawning new processes,
; so having a few always ready to go is a good idea.
; the offset is that they will be taking up memory that your system
; might otherwise be able to use for other things
pm.min_spare_servers = 1
; the inverse of the former. if there's nothing going on,
; how many spare processes are we allowed to keep around?
; again, fewer means more memory on the system for other things,
; but more means less of a delay if an influx of requests comes in
pm.max_spare_servers = 3
socket.conf
Socke configuration for the php-fpm listener.
[www]
listen = /var/run/php5-fpm.socket
status.conf
Status monitoring for php-fpm.
[www]
pm.status_path = /status
Restart the php-fpm service.
sudo service php5-fpm restart
Check the php5-fpm version.
php5-fpm -v