view modules/website/manifests/php.pp @ 482:d83de9b3a62b default tip

Update hiera.yaml within Puppet config Forgot that we manage it from here. Now has content to match new packages
author IBBoard <dev@ibboard.co.uk>
date Fri, 30 Aug 2024 16:10:36 +0100
parents 2c3e745be8d2
children
line wrap: on
line source

class website::php(
    $suffix = '',
    $module = undef,
    $extras = [],
    ) {
  include ::apache::params
  $pcre_jit = 1

  if $facts["os"]["name"] == 'Ubuntu' {
    # Ubuntu doesn't prefix its ini files as created here
    # and has a different way of handling ordering
    $ini_prefix_10 = ''
    $ini_prefix_20 = ''
  }
  else {
    fail("Unsupported OS: ${facts['os']['name']}")
  }

  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-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
        },
        'pm_start_servers' => 5,
        'pm_min_spare_servers' => 5,
        'pm_max_spare_servers' => 10,
      },
    },
    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
      # The new module is typed, so we need ints instead of "16M"
      'PHP/upload_max_filesize' => 16777216,
      'PHP/post_max_size' => 16777216,
      'Data/date.timezone' => 'UTC',
    },
    cli_settings => {
      'apc.enable_cli' => 1 ,
    },
    extensions => {
      ctype => {
        ini_prefix => $ini_prefix_20,
      },
      gd => {
        ini_prefix => $ini_prefix_20,
      },
      iconv => {
        ini_prefix => $ini_prefix_20,
      },
      mbstring => {
        ini_prefix => $ini_prefix_20,
      },
      opcache => {
        ensure => present,
        ini_prefix => $ini_prefix_10,
        zend => true,
        settings => {
          'opcache.enable' => 1,
          'opcache.enable_cli' => 1,
          'opcache.interned_strings_buffer' => 32,
          'opcache.max_accelerated_files' => 15000,
          'opcache.max_wasted_percentage' => 3,
          'opcache.memory_consumption' => 256,
          'opcache.save_comments' => 1,
          'opcache.revalidate_freq' => 60,
          'opcache.huge_code_pages' => 0,
        }
      },
      xml => {
        ini_prefix => $ini_prefix_20,
      },
    } + $extras,
  }
  apache::custom_config { "php.conf":
    ensure => present,
    source => "puppet:///modules/website/php.conf",
    filename => "php.conf",
  }
  class { ['apache::mod::proxy', 'apache::mod::proxy_fcgi']:}
}