view modules/website/manifests/php.pp @ 422:8421eb25c329

Fix PHP extension loading CentOS numbers the files, and the Puppet module doesn't clear out the old values, so we double-loaded. After deleting, it only puts specific ones back and so we need to specify more now rather than relying on the installers
author IBBoard <dev@ibboard.co.uk>
date Sat, 08 Oct 2022 20:58:14 +0100
parents 0c627ff3a7c3
children b91e948e8645
line wrap: on
line source

class website::php(
    $suffix = '',
    $module = undef,
    $extras = [],
    ) {
  include ::apache::params
  if $osfamily == 'RedHat' {
    # Work around SELinux "denied execmem" warnings from preg_match JITing
    $pcre_jit = 0
  }
  else {
    $pcre_jit = 1
  }

  file { '/run/php/':
    ensure => directory,
  } ->
  class { '::php':
    ensure => present,
    manage_repos => false,
    fpm => true,
    fpm_service_enable => true,
    fpm_service_ensure => 'running',
    fpm_pools => {
      'www' => {
        'listen' => '/run/php/php-fpm.sock',
        'listen_owner' => $::apache::params::user,
        'listen_group' => $::apache::params::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 => {
        ini_prefix => '20-',
      },
      iconv => {
        ini_prefix => '20-',
      },
      mbstring => {
        ini_prefix => '20-',
      },
      opcache => {
        ini_prefix => '10-',
        zend => true,
        settings => {
          '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 => {
        ini_prefix => '20-',
      },
    } + $extras,
  }
  apache::custom_config { "php.conf":
    ensure => present,
    source => "puppet:///modules/website/php.conf"
  }
  class { ['apache::mod::proxy', 'apache::mod::proxy_fcgi']:}
}