Contents

PHP FPM Configurations

Info
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

1
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.

1
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:

1
adduser --no-create-home --disabled-login pooluser

Create the new pool file (copy the existing one):

1
cp /etc/php/7.2/fpm/pool.d/www.conf /etc/php/7.2/fpm/pool.d/newpool.conf

Modify the new pool’s configurations:

1
nano /etc/php/7.2/fpm/pool.d/newpool.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# 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
Note
Other configurations may be needed. The above ones are the basics to create a new pool.

Change the files ownership to the new user:

1
chown -R pooluser:pooluser /path/to/code