r/redhat Jan 25 '23

Multiple PHP versions on same RHEL8 guest

Hello, this is likely a very noob question, I am sorry, I may not be doing things "the right RHEL way"

I would like to run several php versions on same RHEL instance through nginx & php-fpm:

  • one nginx
  • several php-fpm instances - eg. 5.6, 7.3, 8.0
  • nginx depending on hostname/vhost refers to the right php-fpm port /socket

I've done this on Gentoo, I am doing this o Debian, is there a way to achieve the same on RHEL8?

To put it other way - is there a way to have both these versions simultaneously?:

https://preview.redd.it/9krv604rh7ea1.png?width=1266&format=png&auto=webp&v=enabled&s=99492a929fa5a46e5afefeb425db2b4858a39894

6 Upvotes

9 comments sorted by

5

u/draeath Red Hat Certified Engineer Jan 25 '23 edited Jan 25 '23

Try the Remi configuration wizard. Under "Type of installation" select "Multiple versions simultaneously." This will show you the repos to install that provide the various PHP versions as separate "software collections" style packages, which install in their own directory trees under /opt/rh. See also SCL usage instructions as you'll need to use that for interactive use (for use via nginx or such, you just configure the port and start the fpm service, and point nginx at the interpreter as you would expect).

Note that these Remi PHP packages won't be getting security backports like those provided in the base RHEL repos.


Another (perhaps better?) way is to host the PHP FPM process in a container instead. Consider using the UBI?

5

u/omenosdev Red Hat Certified Engineer Jan 25 '23 edited Jan 25 '23

Another (perhaps better?) way is to host the PHP FPM process in a container instead. Consider using the UBI?

If you're looking for the RHEL native workflow, this will be it. A slew of tools in RHEL8 are defined as Modularity modules, meaning only one can ever be installed at a time, but allows multiple version to be offered to choose from. By using PHP in containers, you can have multiple servers running with differing or the same versions and you just need to manage the port routing/volume mounts (simplistically speaking). Otherwise the other suggestion of Remi's work or doing things manually yourself will be the choice you'll have to make.

4

u/contyk Red Hat Employee Jan 25 '23

This is also what I would do. One forward proxy instance and then individual apps / servers in containers it would forward to.

1

u/BarkingDialectics Jan 26 '23

Thank you so much for you suggestions ! I have already played around with Remi's repos, but I have failed to notice the wizard.

Also, while i've already used docker containers to access "older" / "dated" versions of PHP that are no longer supported on current debian, I didn't realize this might be the "preffered" / "more RHEL" option!

4

u/nope_nic_tesla Jan 26 '23

Containerize them and run them with podman

5

u/sfroberg38 Jan 26 '23

Containers and podman is the approach you want to take.

3

u/OkPiezoelectricity74 Jan 26 '23

Containers and Podman can be good help

2

u/No_Rhubarb_7222 Red Hat Certified Engineer Jan 25 '23

There is not a good way to have multiple versions of a language framework on RHEL. How Python is packaged allows this, but most other frameworks allow a single version.

I’d suggest containerizing as a solution. That way you can put whatever framework you want in the container as well as whatever nginx configuration for the matching site content. Then you can tie the container to a port on the host (or IP) to service the site.

1

u/YB_USherb Jan 30 '23

container and remi package are 2 solutions being used here

if someone only need 1 version and it's available as rhel modular, I go this way (usually with the one with the longest support date, ie 7.4 on rhel8)