Understanding PHP Pools

As described in Understanding System Users all sites deployed via SpinupWP are owned by a unique system user. This provides security isolation on the server because a site user cannot read or modify another site’s files.

Each site is also deployed with a PHP-FPM resource pool, which is owned by the site user. This prevents PHP scripts from reading or modifying files outside of the current site’s root directory. Meaning, if a malicious user were to gain access to a site on your server, they would be unable to infect other sites.

In addition to providing security isolation between sites, PHP pools allow you to configure PHP on a per-site basis. Values within your php.ini file can be overridden in a pools config file.

Nginx (PHP-FPM)

In Nginx, PHP requests are forwarded to your site’s PHP pool, like so:

location ~ \.php$ {
    try_files $uri =404;

    include fastcgi.conf;
    fastcgi_pass unix:/run/php/php{php_version}-{user}.sock;
}

CLI

PHP on the command line works differently than PHP-FPM. This is because PHP on the CLI runs as the current system user issuing the command. For example, if logged in as abe, the following command would run as the abe user:

php -r 'echo getcwd();'

The same goes for WP-CLI commands, even when specifying the location of the WordPress install:

wp core update --path=/sites/turnipjuice.media/files

This means that site users, will be unable to execute PHP scripts they’re unable to read. Nor will they be able to modify other sites via WP-CLI.