NGINX + PHP-FPM + FTP: Multiple websites per pool

In several situations, with some custom users, we need to stretch to the max the resources and the number of websites inside a single server. For that, let’s use the PHP-FPM with by user pool and directory with different users for FTP access.

First we need to start with the Setup of the services.

For this "how to", we will use CentOS 7 as distribuition with the following versions:

  • NGINX, version: 1.17.10 (mainline release)
  • PHP-FPM, version: 7.3.18
  • MariaDB, version: 10.4 (Stable)

NGINX Installation

Create the file nginx.repo inside /etc/yum.repos.d/ to allow the installation of NGINX mainline release. Attention, this will work on a CentOS 6 because we are using variables to define the version of the OS release $releasever.

name=nginx repo

We will do the installation after the MariaDB installation to interact with PHP-FPM configuration.

MariaDB Installation

To install MariaDB 10.4, please create the file MariaDB.repo inside /etc/yum.repos.d/. You can check this information on official MariaDB repositories.

# MariaDB 10.4 CentOS repository list - created 2020-05-20 23:26 UTC
name = MariaDB
baseurl =
  • If you prefer another version, please change 10.4 to 10.3 or 10.2 or even 10.5 (Beta).

After the file is in place, install MariaDB with:

yum install MariaDB-server MariaDB-client

In this step, you only need to ensure that the version to install is 10.2. If yes, you can accept by typing yes.

As soon as the proccess completes, let's step the default password for the MariaDB Server and remove all the dummy information.

systemctl enable mariadb # this will add the mariadb to startup on boot
systemctl start mariadb


Enter current password for root (enter for none): <Press Enter>
Set root password? [Y/n] y
New password: <new password here>
Re-enter new password: <new password here>
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

At this point, your MariaDB Server is installed and configured with a new password for root access. You can try to access by using the following command:

mysql -uroot -p<new password here>

And the expected behaviour:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 29634
Server version: 10.4.13-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

After this proccess, we are ready to start the installation of PHP-FPM and NGINX. We are going to start with PHP-FPM to allow you to define the name of PHP sockets to write it down on NGINX site configuration.

To install PHP-FPM, let's use the remi repositories.

First, ensure that epel-release is installed.

yum install -y epel-release
  • This will work in CentOS 7, for version 6, you will need to use the full .rpm file.
sudo yum install$(rpm -E '%{rhel}').noarch.rpm

After epel-release installation, install the remi repository.

yum install$(rpm -E '%{rhel}').rpm

Based on title of this article, we will use the PHP 7.3, so, to avoid using the --enablerepo=remi-php73, let's enable this repo permanently on file.

vi /etc/yum.repos.d/remi-php73.repo

On the block [remi-php73], change the value enabled=0 to enabled=1. This will ensure on future updates or installations, the version of package that will search / install will be the 7.3.

For this example, let's install a few packages needed by some of Frameworks / CMS.

yum install php-pecl-zip php-pecl-igbinary php-intl php-mbstring php-opcache php-common php-pecl-msgpack php-fpm php-pecl-apcu php-gd php-devel php-pear php-pdo php-pecl-memcached php-mysqlnd php-cli php-mcrypt php-pecl-memcache php-nrk-Predis php-xml php-xmlrpc php-pgsql php-pecl-pthreads php-soap php-process
  • This will install a few more packages as dependencies.

Now that we have the PHP-FPM and packages installed, let's install the nginx package.

yum install nginx

Because we have choosen the mainline, this will installed the latest mainline version from repositories.

Tiago Reis

Tiago Reis