Multiple version of php.

Go to page

Well-Known Member

Im looking for same tutorials about installing multiple diffrent versions of php. For example 5.6, 7.0 and 7.1. Every tutorial found is very old and the process installation based on php from source. Can't i install from ports ? Someone has experience with it and could share a knowledge ? I would be gratefull.

Son of Beastie

Yeah, that's what I would do. Especially because using older PHP versions can always become a nasty security risk (depending on the version being used of course).

The example you're showing is of course also possible, however you'd be working outside the package system (so not using Ports or packages but manual installations). Although you could utilize parts of the Ports system. For example using # make extract is enough to extract the vanilla source tree, which you could then use to manually install it to a different specific location.

But it is bad practice. Using older (obsolete) PHP versions can come with serious security risks.

I was looking for a cleaner way to do it (to have php 5.6 + 7.1 on the same system), but it seems the situation is the same here ? It's a bit sad when you compare to some linux distributions where you can have different concurrent versions really easily. In the mean time, if you (bryn1u) have found a better solution, please let us know

Well-Known Member

You can do it manually. For example mydevil.net has a 3 diffrent version of php. Server based on FreeBSD-11

Code:

PHP: [5.6: 0/3] [7.0: 0/3] [7.1: 0/3]

You can choose version by .htaccess for example. Each site based on diffrent version.
Look for centos tutorial. I think you can do it compiled from ports or from php site manually. Please let me know if you can do something. I would be grateful. And yes, php version per jail is a nightmare for admin when so many users wants to use all version of php.

Administrator

Like I said, things have changed. Back in the day those if..then..else make.conf constructs were needed to make it work at all. Since then /usr/ports/Mk/bsd.default-versions.mk was created and the ports system itself got convenient "default" selectors. Those "old" make.conf constructs either don't work or set the wrong variables.

Active Member

If you run multiple pools at the same time and want a different PHP version for some of them.
The problem with jails is that it becomes way too complicated easily, due to the need to mount and unmount homedirectories.
And you need the users in all jails, which leads to having to use LDAP, which is another thing that can and does go wrong.

If I could run PHP 7.2 and 7.3 at the same time, I'd just point the apache or nginx config at the socket and that's it.
I run all my PHPs chrooted and have various of the hosts' directories nullfs mounted to each homedirectory.

Administrator

In my opinion you're trying to cram too much onto one big system. I'm more in favor of splitting things up over multiple, smaller, servers. Yes, it increases complexity slightly but you gain a lot of resilience (load-balancing, fault-tolerance). It also makes it easier to take one server out, update it and put it back, without having to take down everything. If you put all your eggs into one basket, as soon as the bottom falls out, you lose all your eggs.

Active Member

Well, we found that there is enough resiliency in a single server for our purposes. If you had multiple servers, you'd need a shared filesystem, which is NFS in the case of FreeBSD, which is also orders of magnitudes slower than a local filesystem, especially for serving PHP. Latency is very noticeable when serving files via http.
And when you have NFS, that NFS server is again a single point of failure.

Ravenports can apparently do it, but I could never get myself committing to that....