view modules/website/manifests/php.pp @ 399:2c6065b5be5e

Switch to config-based PHP extensions This makes it compatible with Ubuntu, otherwise it keeps trying to re-install the same module because the "phpX.X" package is a virtual package and the Puppet handling of Ubuntu's "is it installed" system is incapable of saying "yes" when a virtual package is installed.
author IBBoard <dev@ibboard.co.uk>
date Wed, 20 Apr 2022 19:08:14 +0100
parents df5ad1612af7
children f354100b688a
line wrap: on
line source

class website::php(
    $suffix = '',
    $module = undef,
    $extras = [],
    ) {
  if $osfamily == 'RedHat' {
    $listener_user = 'apache'
    $listener_group = 'apache'
    # Work around SELinux "denied execmem" warnings from preg_match JITing
    $pcre_jit = 0
  }
  else {
    $listener_user = 'www-data'
    $listener_group = 'www-data'
    $pcre_jit = 1
  }
  class { '::php':
    ensure => present,
    manage_repos => false,
    fpm => true,
    fpm_pools => {
      'www' => {
        'listen' => '/run/php-fpm/www.sock',
        'listen_owner' => $listener_user,
        'listen_group' => $listener_group,
        'slowlog' => '/var/log/php-fpm/www-slow.log',
        'security_limit_extensions' => ['.php', '.html'],
        'php_admin_value' => {
          'memory_limit' => '256M',
        },
        'php_value' => {
#          'session.save_path' => '/var/lib/php/session' # Ubuntu uses plural, CentOS uses singular
        },
      },
    },
    dev => false,
    composer => false,
    pear => false,
    settings => {
      'PHP/default_charset' => 'UTF-8',
      'PHP/pcre.jit' => $pcre_jit,
      # Space isn't scarce these days - increase default sizes
      'PHP/upload_max_filesize' => "8M",
      'PHP/post_max_size' => "8M",
      'Data/date.timezone' => 'UTC',
    },
    extensions => {
      gd => {},
      mbstring => {},
      opcache => {
        settings => {
          'zend_extension' => 'opcache.so',
          'opcache.enable' => 1,
          'opcache.enable_cli' => 1,
          'opcache.interned_strings_buffer' => 8,
          'opcache.max_accelerated_files' => 10000,
          'opcache.memory_consumption' => 128,
          'opcache.save_comments' => 1,
          'opcache.revalidate_freq' => 1,
        }
      },
      xml => {},
    } + $extras,
  }
  apache::custom_config { "php.conf":
    ensure => present,
    source => "puppet:///modules/website/php.conf"
  }
  class { ['apache::mod::proxy', 'apache::mod::proxy_fcgi']:}
}