PHP-FPM Configurations
Table of Contents
PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites.
Install #
apt install php-fpm
Configuration #
The FPM’s main configuration file is /etc/php/$VERSION/fpm/php.ini
.
Memory limit #
Maximum amount of memory that the PHP script can use.
memory_limit = 128M
FPM Pool #
It is possible to isolate the php codes with fpm pools.
First, create a new user to the new pool:
adduser --system --ingroup www-data --shell "/sbin/nologin" --no-create-home pooluser
Create the new pool file (copy the existing one):
cp /etc/php/$VERSION/fpm/pool.d/www.conf /etc/php/$VERSION/fpm/pool.d/newpool.conf
Modify the new pool’s configurations:
nano /etc/php/$VERSION/fpm/pool.d/newpool.conf
# The section name must be changed from [www]
[newpool]
...
# The user who will be run the process
user = pooluser
group = pooluser
...
# The new pool's socket's name
listen = /run/php/php-fpm-newpool.sock
Other configurations may be needed. The above ones are the basics to create a new pool.
Change the files ownership to the new user:
chown -R pooluser:pooluser /path/to/code