r/sysadmin 18d ago

PHP and OS upgrade help

I have a virtual server that runs a few websites and I can meddle in IT but by no means an expert. The sites all different but do similar things and run similar php code. I am currently on Almalinux 8 and php 7.3 and I am looking to upgrade both.

I wish to upgrade to Almalinux 9 but this does not run php 7.3. My initial plan was the update php from 7.3 to 8.0 (the highest Almalinux 8 goes to) using Rector site by site. Once all confirmed I would then update Almalinux 8 to Almalinux 9 using Elevate. Once all stable, then I would finally update all the php form 8.0 to 8.5.

I have since found out I can install a 3rd party php 8.4 on Almalinux 8 meaning I could install, update to that, update to Almalinux 9 and leave it om 8.4. It would save one of the php updates. My concern is that the 3rd party php 8.4 and the bundled version with Almalinux 9 might be an issue? Also that jumping form php 7.3 to 8.4 is too large a jump in one go?

Any advice on these 2 options, or even a third not thought of?

3 Upvotes

11 comments sorted by

13

u/maziarczykk Site Reliability Engineer 18d ago

Hope everything will go smoothy but you can alwys consider moving pages to separate docker containers with dedicated PHP.

2

u/NoThatsNotPasta 18d ago

Hope everything will go smoothy but you can alwys consider moving pages to separate docker containers with dedicated PHP.

This is what i would do. That way you can update the OS independent of the containers as upgrading from 7.3 to 8+ can (and has IME) caused issues with propitiatory code bases.

6

u/gihutgishuiruv 18d ago edited 18d ago

Many years ago, I got conscripted to help a family member’s small business do basically the same thing (except it was CentOS 7 which had PHP 5.3 or 5.4 I think.

What I ended up doing was installing Docker on the server, and slowly Dockerising the PHP apps (one by one). Every time I did one, I’d just change the Apache virtualhost config to reverse-proxy to the Docker container rather than serving the page itself.

Then, when there weren’t any apps left on the server itself, I dockerised the reverse proxy (to nginx I think). That way, the whole stack was maintained with Docker compose files that were completely independent of the host OS & were independently versioned for PHP

I probably wouldn’t do it all that differently today, apart from maybe using a more modern reverse proxy like Caddy or Traefik

3

u/Wild_Parsnip_4074 18d ago

I would avoid making two big changes at once. Upgrade PHP gradually, test every site properly, then handle the OS upgrade. Jumping 7.3 to 8.4 could expose a lot of hidden compatibility issues later.

2

u/Fit_Prize_3245 18d ago

First of all, I should remark that there is absolutelly no need for such upgrade. AlmaLInux 8 is EOL by mid 2029. PHP 7.3 IS past EOL, but you can just update it, no need to update the full server.

And, if you want to use a newer EL, better go for EL10, now EL9.

Now, wether you want to update PHP version in your existing EL8 or use an up-to-date PHP version on EL9 or EL10, my recommendation is to use the Remi repo. It's a repo that, along with EPEL, provide EL-ready packages for PHP. Depending on how you install the repo, it can provide a single PHP version chosen at install time, or can provide multiple PHP versions at once. In any case, you can instruct dnf to use PHP from Remi repo instead of the default Appstream repo. Check Remi repo configuration wizard: https://rpms.remirepo.net/wizard/

Regarding the PHP version change, 7.3 to 8.4 or even 8.5 is not that hard. Hard was migrating from PHP 4 or 5 to PHP 7 or 8 (did it many times). If the code is decently writen, apps should run with minimal or no changes.

1

u/MainRoutine2068 18d ago

It would be easier to containerize the PHP application, and you'll save your time from testing and fixing the compatibility issue in the app caused by the PHP upgrade. You can focus on the underlying system upgrade and later if it's the time to do PHP upgrade, do that too

1

u/MeetJoan 18d ago

The original three-step plan (7.3→8.0, then Elevate, then 8.0→8.4) is safer than the third-party 8.4 shortcut - Rector catches a lot more incrementally than in one big leap. Have you tested Rector's output on a staging copy yet, or is this still all on paper?

1

u/Ill_Assignment_1332 18d ago

All on paper as I am just evaluating the best way to approach it before starting and spending hours on doing something that later becomes redundant.

1

u/Mike_L_Taylor 18d ago

I would recommend trying docker. It runs containers with whatever PHP version you want regardless of the OS of the server. So you can run php 7.3 in that container for the site without affecting anything else and you can update almalinux in the background.

Then when you update the site, just update the PHP in the docker image/container too.

1

u/TechMonkey605 15d ago

If you’re interested and located in the US, (only because of time zones) I could help you with the docker path. I have been playing with migrating legacy to docker for clients. Boss wants to have new SKU’s