Skip to content

Commit 5285ae3

Browse files
author
Ciaran McCrisken
committed
(MODULES-10899) Install PHP 7 by default on SLES >= 15
On SLES >= 15 it appears as though the `apache2-mod_php5` package is no longer available in the default repo. This commit ensures that the default value for the $php_version parameter is 7 on SLES >= 15 and the appropriate `apache2-mod_php7` package is used. The spec test expectations have also been updated based on the changes.
1 parent 0d175da commit 5285ae3

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

manifests/mod/php.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
$libphp_prefix = 'libphp'
1717
) inherits apache::params {
1818
include apache
19-
if (versioncmp($php_version, '7') <= 0) {
19+
if (versioncmp($php_version, '8') < 0) {
2020
$mod = "php${php_version}"
2121
} else {
2222
$mod = 'php'
@@ -78,7 +78,7 @@
7878
id => "php${_php_major}_module",
7979
path => "${apache::lib_path}/mod_${mod}.so",
8080
}
81-
} elsif (versioncmp($php_version, '7') <= 0) {
81+
} elsif (versioncmp($php_version, '8') < 0) {
8282
::apache::mod { $mod:
8383
package => $_package_name,
8484
package_ensure => $package_ensure,

manifests/params.pp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -698,26 +698,27 @@
698698
$logroot_mode = undef
699699
$lib_path = '/usr/lib64/apache2' #changes for some modules based on mpm
700700
$mpm_module = 'prefork'
701-
702701
if versioncmp($::operatingsystemrelease, '15') < 0 {
703702
$default_ssl_cert = '/etc/apache2/ssl.crt/server.crt'
704703
$default_ssl_key = '/etc/apache2/ssl.key/server.key'
704+
$php_version = '5'
705705
} else {
706706
$default_ssl_cert = '/etc/apache2/ssl.crt/default-server.crt'
707707
$default_ssl_key = '/etc/apache2/ssl.key/default-server.key'
708+
$php_version = '7'
708709
}
710+
$suphp_configpath = "/etc/php${php_version}/apache2"
709711
$ssl_sessioncache = '/var/lib/apache2/ssl_scache(512000)'
710712
$suphp_addhandler = 'x-httpd-php'
711713
$suphp_engine = 'off'
712-
$suphp_configpath = '/etc/php5/apache2'
713-
$php_version = '5'
714714
if versioncmp($::operatingsystemrelease, '11') < 0 or versioncmp($::operatingsystemrelease, '12') >= 0 {
715-
$mod_packages = {
715+
$mod_packages = {
716716
'auth_kerb' => 'apache2-mod_auth_kerb',
717717
'auth_gssapi' => 'apache2-mod_auth_gssapi',
718718
'dav_svn' => 'subversion-server',
719719
'perl' => 'apache2-mod_perl',
720720
'php5' => 'apache2-mod_php5',
721+
'php7' => 'apache2-mod_php7',
721722
'python' => 'apache2-mod_python',
722723
'security' => 'apache2-mod_security2',
723724
'worker' => 'apache2-worker',

spec/acceptance/mod_php_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ class { 'apache::mod::php': }
4545
describe file("#{apache_hash['mod_dir']}/php7.conf") do
4646
it { is_expected.to contain 'DirectoryIndex index.php' }
4747
end
48+
elsif os[:family] == 'sles' && os[:release].to_i >= 15
49+
describe file("#{apache_hash['mod_dir']}/php7.conf") do
50+
it { is_expected.to contain 'DirectoryIndex index.php' }
51+
end
4852
else
4953
describe file("#{apache_hash['mod_dir']}/php5.conf") do
5054
it { is_expected.to contain 'DirectoryIndex index.php' }

spec/classes/mod/php_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@
207207

208208
# all the following tests are for legacy php/apache versions. They don't work on modern ubuntu and redhat 8
209209
next if (facts[:os]['release']['major'].to_i > 15 && facts[:os]['name'] == 'Ubuntu') ||
210+
(facts[:os]['release']['major'].to_i >= 15 && facts[:os]['name'] == 'SLES') ||
210211
(facts[:os]['release']['major'].to_i >= 9 && facts[:os]['name'] == 'Debian') ||
211212
(facts[:os]['release']['major'].to_i >= 8 && (facts[:os]['name'] == 'RedHat' || facts[:os]['name'] == 'CentOS'))
212213

0 commit comments

Comments
 (0)