Forge Home

167,496 downloads

10,296 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.2.4 (latest)
  • 1.2.3
  • 1.2.2
  • 1.2.1
  • 1.2.0
  • 1.1.1
  • 1.1.0
  • 1.0.0
  • 0.3.12
  • 0.3.11
  • 0.3.10
  • 0.3.9
  • 0.3.8
  • 0.3.7
  • 0.3.6
  • 0.3.5
  • 0.3.4
  • 0.3.3
  • 0.3.2
  • 0.3.0
  • 0.2.5
  • 0.2.4
  • 0.2.3
  • 0.2.2
  • 0.2.1
  • 0.2.0
released Jun 25th 2020
This version is compatible with:
  • Puppet Enterprise 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 >=2.7.20 <8.0.0
  • , , ,

Start using this module

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

Add this module to your Puppetfile:

mod 'thias-php', '1.2.4'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add thias-php
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install thias-php --version 1.2.4

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

thias/php — version 1.2.4 Jun 25th 2020

puppet-php

Overview

Install PHP packages and configure PHP INI files, for using PHP from the CLI, the Apache httpd module or FastCGI.

The module is very Red Hat Enterprise Linux focused, as the defaults try to change everything in ways which are typical for RHEL, but it also works on Debian based distributions (such as Ubuntu), and support for others should be easy to add.

  • php::cli : Simple class to install PHP's Command Line Interface
  • php::fpm::daemon : Simple class to install PHP's FastCGI Process Manager
  • php::fpm::conf : PHP FPM pool configuration definition
  • php::ini : Definition to create php.ini files
  • php::mod_php5 : Simple class to install PHP's Apache httpd module
  • php::module : Definition to manage separately packaged PHP modules
  • php::module::ini : Definition to manage the ini files of separate modules

Examples

Create php.ini files for different uses, but based on the same template :

php::ini { '/etc/php.ini':
  display_errors => 'On',
  memory_limit   => '256M',
}
php::ini { '/etc/httpd/conf/php.ini':
  mail_add_x_header => 'Off',
  # For the parent directory
  require           => Package['httpd'],
}

Install the latest version of the PHP command line interface in your OS's package manager (e.g. Yum for RHEL):

include '::php::cli'

Install version 5.3.3 of the PHP command line interface :

class { 'php::cli': ensure => '5.3.3' }

Install the PHP Apache httpd module, using its own php configuration file (you will need mod_env in apache for this to work) :

class { 'php::mod_php5': inifile => '/etc/httpd/conf/php.ini' }

Install PHP modules which don't have any configuration :

php::module { [ 'ldap', 'mcrypt' ]: }

Configure PHP modules, which must be installed with php::module first :

php::module { [ 'pecl-apc', 'xml' ]: }
php::module::ini { 'pecl-apc':
  settings => {
    'apc.enabled'      => '1',
    'apc.shm_segments' => '1',
    'apc.shm_size'     => '64',
  }
}
php::module::ini { 'xmlreader': pkgname => 'xml' }
php::module::ini { 'xmlwriter': ensure => 'absent' }

Install PHP FastCGI Process Manager with a single pool to be used with nginx. Note that we reuse the 'www' name to overwrite the example configuration :

include '::php::fpm::daemon'
php::fpm::conf { 'www':
  listen  => '127.0.0.1:9001',
  user    => 'nginx',
  # For the user to exist
  require => Package['nginx'],
}

Then from the nginx configuration :

# PHP FastCGI backend
upstream wwwbackend {
  server 127.0.0.1:9001;
}
# Proxy PHP requests to the FastCGI backend
location ~ \.php$ {
  # Don't bother PHP if the file doesn't exist, return the built in
  # 404 page (this also avoids "No input file specified" error pages)
  if (!-f $request_filename) { return 404; }
  include /etc/nginx/fastcgi.conf;
  fastcgi_pass wwwbackend;
}
# Try to send all non-existing files to the main /index.php
# (typically if you have a PHP framework requiring this)
location @indexphp {
  if (-f $document_root/index.php) { rewrite .* /index.php last; }
}
try_files $uri @indexphp;