Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RHEL8: keeps installing php7.2.4 #684

Open
abctaylor opened this issue May 2, 2023 · 2 comments
Open

RHEL8: keeps installing php7.2.4 #684

abctaylor opened this issue May 2, 2023 · 2 comments

Comments

@abctaylor
Copy link

Hello - after trying many hacks and tricks in previous issues submitted, this still appears to be very non-trivial to do, and the php_version setting is essentially useless. How can a different version of PHP be installed? No matter what you enter for php_version, it still chooses something different.

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6
  • Module version: 8.2.0

How to reproduce (e.g Puppet code you use)

  class { '::php::globals':
    php_version => '8.2',
    config_root => '/etc/php/8.2',
  }->class { '::php':
    manage_repos   => false,
    package_prefix => 'php82-php-',
    settings       => {
      'PHP/max_execution_time'  => '90',
      'PHP/max_input_time'      => '300',
      'PHP/memory_limit'        => '1G',
      'PHP/post_max_size'       => '1G',
      'PHP/upload_max_filesize' => '10G',
      'Date/date.timezone'      => 'Europe/London',
    },
  }

What are you seeing

PHP 7.2.4 gets installed, no matter what.

What behaviour did you expect instead

PHP 8.2 gets installed

@abctaylor
Copy link
Author

The issue is because the OS' default repo (e.g. rhel-8-for-x86_64-appstream-rpms) takes preference, and this has an older RPM than Remi.

@jlemire3
Copy link

jlemire3 commented Oct 24, 2024

I know this is an older issue, but it's still open and relevant, so I wanted to post a workaround for anyone having trouble with this installing PHP 7 instead of PHP 8.

I understand that Oracle Linux isn't officially supported by the module, and that RHEL 7 is the only "officially" supported version, but the module works in Oracle Linux 8 aside from the package issues.

My current environment consists of:
Puppet: 8
Agent version: 8.6.0
Module version: 10.2.0
OS: Oracle Linux 8.10
PHP Version: 8.3 (Remi)

With Oracle Linux 8, the default AppStream repo wants to use 7.4 by default, but also has 8.2 available to use. Unfortunately trying to specify PHP 8.2 in the PHP module has the same problems as this issue, and it will not install anything newer than 7.2.4.

I have been trying to install PHP 8.3 using this module and I've had it working for months by manually creating the remi-release repository and setting my default DNF module for PHP to php:remi-8.3. This would set the expected version of PHP as the default module to install, and installations would use 8.3, but it would cause corrective changes every run because the PHP module would conflict with my manual packages trying to change it back to PHP 7.

This worked for my needs, but it was frustrating having the corrective changes every run, so I spent some time playing with configurations until I found a way to have the php module install the correct package versions on its own without having to introduce corrective changes.

In hindsight, the cleanest workaround to this issue was staring me right in my face by using php::globals to overwrite the package information. It took a lot of reading through the code trying to reverse engineer how the package management stuff was actually working, and I was misunderstanding how to use php::globals for awhile too. I spent quite a bit of time trying to get the php class parameter 'package_prefix' working but to no avail. What ultimately got everything working right was setting 'rhscl_mode' to 'remi' and 'php_version' to 'php83' in php::globals, and making sure to the remi repository is installed before I let the php module run.

My workaround is still not perfect and ultimately it would be great to get this code fixed so this isn't necessary, but here is the code I have running in my production environment to enable this:

# Installs the following 3 repos in '/etc/yum.repos.d/': remi-modular.repo, remi.repo, remi-safe.repo
package { 'remi-release':
  ensure   => 'present',
  source   => 'https://rpms.remirepo.net/enterprise/remi-release-8.rpm',
  provider => 'dnf',
}
class { 'php::globals':
  php_version => "php83",
  rhscl_mode  => 'remi',
  require         => [Package['remi-release']],
}
-> class { 'php':
  ensure                => $ensure,
  manage_repos   => false,
  fpm                    => true,
  composer          => true,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants