Multiple version of php.

Hello,

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.

Regards,
 
You can't install them next to each other, they conflict.
 
Only using a Jail (virtual system) will resolve this. As SirDice said: the packages themselves conflict, they get installed to the same location so they cannot co-exist on one system.
 
ShelLuser
What do u mean virtualsystem ? 1 jail 1 php version ?
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.
 
You can manually compile and install php directly from php.net without using ports. I have 3 different php versions in the same environment with no problems.
 
Old thread, but just in case, here is something I used to do a few years ago, using ports:

cd /usr/ports/lang/php55
make config
make PREFIX=/usr/local/php55 PHPBASE=/usr/local/php55 install clean DISABLE_CONFLICTS=1
make PREFIX=/usr/local/php55 PHPBASE=/usr/local/php55 install clean DISABLE_CONFLICTS=1
cd /usr/ports/lang/php55-extensions/
make config

And then Apache+FCGIWrapper.

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 :)

Regards.
 
The DirectAdmin control panel comes preconfigured to allow two versions of PHP; however it does not use the ports.
 
Quote from another forum:

"BTW, alternative PHP versions can be easily build from ports if you add something like this into /etc/make.conf:
Code:

PHP_ALT=php52 php53 php55 php70 php71
.for port in ${PHP_ALT}
.if ${.CURDIR:M*/ports*/*/${port}*}
PREFIX=/usr/local/${port}
PHPBASE=/usr/local/${port}
DISABLE_VULNERABILITIES=yes
.endif
.endfor"
 
Quote from another forum:

"BTW, alternative PHP versions can be easily build from ports if you add something like this into /etc/make.conf:
Code:

PHP_ALT=php52 php53 php55 php70 php71
.for port in ${PHP_ALT}
.if ${.CURDIR:M*/ports*/*/${port}*}
PREFIX=/usr/local/${port}
PHPBASE=/usr/local/${port}
DISABLE_VULNERABILITIES=yes
.endif
.endfor"


Don't they still conflict?
I can build them all via poudriere (though not in the same repo).
 
Don't they still conflict?
Yes.

Besides that, the 'solution' offered is pretty bad. This may have worked in the past but nowadays the PHP version is set using DEFAULT_VERSIONS, see /usr/ports/Mk/bsd.default-versions.mk.
 
I would love to be able to install different versions of PHP in parallel (and via pkg).

Of course, that would mean being able to compile and install different versions of pecl and pear modules in parallel, too.

But in the end, I only access them via FastCGI - I haven't used mod_php since php-fpm became an option of the port in PHP 5.3.

Sigh. How far away are flavors?
;-)
 
I would love to be able to install different versions of PHP in parallel (and via pkg).
This is a good example for using a jail(8). Each jail can run its own PHP version.

How far away are flavors?
I wouldn't hold my breath waiting for them. Besides that, flavors still won't let you install 2 conflicting packages. It will only make it easier to change dependencies for packages.
 
This is a good example for using a jail(8). Each jail can run its own PHP version.


Yes, but can I run PHP chrooted inside a jail? Can I nullfs-mount stuff inside a chroot inside a jail?

I run several hundred PHP-FPM pools on one server, each chrooted and each having various parts of the system nullfs-mounted into the chroot.
Each pool is also a distinct ZFS filesystem.

I don't want to run a jail for each pool - that would be insane and a nightmare to manage (IMO).
 
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.
 
Yes.

Besides that, the 'solution' offered is pretty bad. This may have worked in the past but nowadays the PHP version is set using DEFAULT_VERSIONS, see /usr/ports/Mk/bsd.default-versions.mk.

I realize this is pretty old but can you expand on this, as I find myself wanting to do the exact same thing. Why is it bad?
 
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.
 
So I shouldn't try to kludge a prefix to each php version (e.g. php71 => /usr/local/php71) in make.conf at all? How else would I go about doing this?
 
Go back to the beginning, why do you need to run two different versions in the first place? What problem are you trying to solve?
 
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.
 
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.
 
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....
 
Back
Top