Forge Home

phpfpm

Puppet module to manage PHP-FPM basic config, php.ini and pools

8,845 downloads

1,876 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 1.1.2 (latest)
  • 1.1.1
  • 1.1.0
  • 1.0.3
  • 1.0.2
  • 1.0.1
  • 1.0.0
released Aug 31st 2020
This version is compatible with:
  • Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >= 4.0.0

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'qtechnologies-phpfpm', '1.1.2'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add qtechnologies-phpfpm
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install qtechnologies-phpfpm --version 1.1.2

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

qtechnologies/phpfpm — version 1.1.2 Aug 31st 2020

puppet-phpfpm

Puppet module to manage PHP-FPM basic config, php.ini and pools.

It has been designed to fit in nicely with our Nginx module: qtechnologies/nginx. If this Nginx module is installed, this module grabs some parameters from it - things are less likely to break if there's only one source of data - especially for the shared sockets locations.

Currently only tested on SUSE, but other platforms should work with the right hiera data.

Instructions

Global Settings

You can also override internal defaults in hiera, if required, e.g.:

phpfpm::conf_dir: /etc/php5/fpm
phpfpm::service: php-fpm
phpfpm::package: php5-fpm
phpfpm::socket_dir: /var/sockets
phpfpm::pid_dir: /var/run
phpfpm::log_dir: /var/log/nginx
phpfpm::www_pool_ini:
  user: nobody
  group: nobody
  listen.mode: '0666'
  pm: dynamic
  pm.max_children: 5
  pm.start_servers: 2
  pm.min_spare_servers: 1
  pm.max_spare_servers: 3
  'env[PATH]': /usr/bin:/bin
  'env[TMP]': /tmp
  'env[TMPDIR]': /tmp
  'env[TEMP]': /tmp
phpfpm::pool_ini:
  user: wwwrun
  group: www
  listen.backlog: -1
  listen.mode: '0666'
  pm: dynamic
  pm.max_children: 9
  pm.start_servers: 3
  pm.min_spare_servers: 2
  pm.max_spare_servers: 4
  pm.max_requests: 10000
  request_slowlog_timeout: 5s
  slowlog: /var/log/$pool.log.slow
  request_terminate_timeout: 300s
  rlimit_files: 131072
  rlimit_core: unlimited
  catch_workers_output: 'yes'
  'env[TMP]': /tmp
  'env[TMPDIR]': /tmp
  'env[TEMP]': /tmp

The global settings will be written whenever the class is included - it is automatically included whenever the pool resource is used.

Creating a Pool

Simply use the phpfpm::pool resource, like this:

      phpfpm::pool { 'www.example.com': }

This will create a pool for the specific web server name based on a template.

It also takes the following paramters:

  • web_server_name - web server name to use, otherwise use the resource name
  • socket_dir - the directory to set up the UNIX sockets in - must match NGINX (does by default)
  • pool_ini - can overwrite the global pool ini data. It is merged, so you only need to specify differences.

Pool Configuration

The pool ini data can be specified through hiera by defining phpfpm::pool_ini - it will be merged across hiera.

Configuring the global php.ini for FPM

If you create hiera data for the php.ini it will manage that as well. E.g.:

################################################################################
#
# PHP FPM Configuration
#
################################################################################
phpfpm::php_ini:
  post_max_size: 30M
  upload_max_filesize: 20M
  date.timezone: '"Australia/Melbourne"'
  variable_orders: EGPCS
  session.save_path: '"/var/lib/web-sessions"'
  memory_limit: 256M

NB: for the strings to be quoted in the php.ini they need to be quoted inside single quotes in the hiera data.

Issues

This module is using hiera data that is embedded in the module rather than using a params class. This may not play nicely with other modules using the same technique unless you are using hiera 3.0.6 and above (PE 2015.3.2+).

It has only been tested on SUSE systems, using SUSE paths - patches for other platforms are welcome - we just need to create internal hiera data for the OS family.