diff --git a/manifests/mod/php.pp b/manifests/mod/php.pp index 57cabb489d..f1c1bba12e 100644 --- a/manifests/mod/php.pp +++ b/manifests/mod/php.pp @@ -43,10 +43,11 @@ } include apache - if (versioncmp($php_version, '8') < 0) { - $mod = "php${php_version}" - } else { + # RedHat + PHP 8 drop the major version in apache module name. + if ($facts['os']['family'] == 'RedHat') and (versioncmp($php_version, '8') >= 0) { $mod = 'php' + } else { + $mod = "php${php_version}" } if $apache::version::scl_httpd_version == undef and $apache::version::scl_php_version != undef { @@ -92,12 +93,11 @@ $_php_version_no_dot = regsubst($php_version, '\.', '') if $apache::version::scl_httpd_version { $_lib = "librh-php${_php_version_no_dot}-php${_php_major}.so" + } elsif ($facts['os']['family'] == 'RedHat') and ($_php_major == 8) { + # RedHat + PHP 8 drop the major version in apache module name. + $_lib = "${libphp_prefix}.so" } else { - # Controls php version and libphp prefix - $_lib = $_php_major ? { - '8' => "${libphp_prefix}.so", - default => "${libphp_prefix}${php_version}.so", - } + $_lib = "${libphp_prefix}${php_version}.so" } $_module_id = $_php_major ? { '5' => 'php5_module', diff --git a/manifests/params.pp b/manifests/params.pp index 05efdfec5d..52975fd199 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -345,13 +345,16 @@ $default_ssl_cert = '/etc/ssl/certs/ssl-cert-snakeoil.pem' $default_ssl_key = '/etc/ssl/private/ssl-cert-snakeoil.key' $ssl_sessioncache = "\${APACHE_RUN_DIR}/ssl_scache(512000)" - if ($facts['os']['name'] == 'Ubuntu') or ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['major'], '11') < 0) { - $php_version = $facts['os']['release']['major'] ? { - '9' => '7.0', # Debian Stretch - '10' => '7.3', # Debian Buster - '20.04' => '7.4', # Ubuntu Foccal Fossal - default => '7.2', # Ubuntu Bionic, Cosmic and Disco - } + $php_version = $facts['os']['release']['major'] ? { + '9' => '7.0', # Debian Stretch + '10' => '7.3', # Debian Buster + '11' => '7.4', # Debian Bullseye + '20.04' => '7.4', # Ubuntu Foccal Fossal + '22.04' => '8.1', # Ubuntu Jammy + default => '7.2', # Ubuntu Bionic, Cosmic and Disco + } + if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '22.04') < 0) or + ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['major'], '11') < 0) { $mod_packages = { 'apreq2' => 'libapache2-mod-apreq2', 'auth_cas' => 'libapache2-mod-auth-cas', @@ -379,9 +382,6 @@ 'xsendfile' => 'libapache2-mod-xsendfile', } } else { - $php_version = $facts['os']['release']['major'] ? { - default => '7.4', # Debian Bullseye - } $mod_packages = { 'apreq2' => 'libapache2-mod-apreq2', 'auth_cas' => 'libapache2-mod-auth-cas', diff --git a/spec/acceptance/mod_php_spec.rb b/spec/acceptance/mod_php_spec.rb index 28dc692b7a..c6323e74ab 100644 --- a/spec/acceptance/mod_php_spec.rb +++ b/spec/acceptance/mod_php_spec.rb @@ -44,6 +44,10 @@ class { 'apache::mod::php': } describe file("#{apache_hash['mod_dir']}/php7.4.conf") do it { is_expected.to contain 'DirectoryIndex index.php' } end + elsif os[:family] == 'ubuntu' && os[:release] == '22.04' + describe file("#{apache_hash['mod_dir']}/php8.1.conf") do + it { is_expected.to contain 'DirectoryIndex index.php' } + end elsif os[:family] == 'redhat' && os[:release] =~ %r{^(8)\b} describe file("#{apache_hash['mod_dir']}/php7.conf") do it { is_expected.to contain 'DirectoryIndex index.php' } diff --git a/spec/classes/mod/php_spec.rb b/spec/classes/mod/php_spec.rb index 4b5b8c8a69..0660c0c05b 100644 --- a/spec/classes/mod/php_spec.rb +++ b/spec/classes/mod/php_spec.rb @@ -45,11 +45,11 @@ { php_version: '8.0' } end - it { is_expected.to contain_apache__mod('php') } + it { is_expected.to contain_apache__mod('php8.0') } it { is_expected.to contain_package('libapache2-mod-php8.0') } it { - is_expected.to contain_file('php.load').with( - content: "LoadModule php_module /usr/lib/apache2/modules/libphp.so\n", + is_expected.to contain_file('php8.0.load').with( + content: "LoadModule php_module /usr/lib/apache2/modules/libphp8.0.so\n", ) } end @@ -69,11 +69,11 @@ { php_version: '8.0' } end - it { is_expected.to contain_apache__mod('php') } + it { is_expected.to contain_apache__mod('php8.0') } it { is_expected.to contain_package('libapache2-mod-php8.0') } it { - is_expected.to contain_file('php.load').with( - content: "LoadModule php_module /usr/lib/apache2/modules/libphp.so\n", + is_expected.to contain_file('php8.0.load').with( + content: "LoadModule php_module /usr/lib/apache2/modules/libphp8.0.so\n", ) } end