view modules/website/manifests/php.pp @ 400:f354100b688a

Switch to Ubuntu-standard PHP FPM socket dir Ubuntu puts /tmp and /run on tmpfs, which gets wiped each reboot. While these directories *can* be nuked, they aren't on other platforms. Using the old paths, Puppet had to recreate the directory each boot. Using the new paths, Ubuntu handles creation within the systemd config. CentOS should just create once, migrate and work.
author IBBoard <dev@ibboard.co.uk>
date Wed, 20 Apr 2022 19:11:39 +0100
parents 2c6065b5be5e
children 76d18a918e7f
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_owner' => $listener_user,
        'listen_group' => $listener_group,
        'listen' => '/run/php/php-fpm.sock',
        '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']:}
}