Multiple version of php.

bryn1u

Well-Known Member

Thanks: 9
Messages: 338

#1
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,
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,613
Messages: 28,158

#2
You can't install them next to each other, they conflict.
 

ShelLuser

Son of Beastie

Thanks: 1,580
Messages: 3,431

#4
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

Son of Beastie

Thanks: 1,580
Messages: 3,431

#6
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.
 
OP
OP
B

bryn1u

Well-Known Member

Thanks: 9
Messages: 338

#7
I will not install old version php, it was only example, couldn't find newer tutorial.
 

Remington

Well-Known Member

Thanks: 136
Messages: 467

#8
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.
 

swix

New Member

Thanks: 1
Messages: 5

#9
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.
 

wattie

New Member

Thanks: 2
Messages: 13

#10
The DirectAdmin control panel comes preconfigured to allow two versions of PHP; however it does not use the ports.
 

wattie

New Member

Thanks: 2
Messages: 13

#11
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"
 

rainer_d

Active Member

Thanks: 4
Messages: 103

#12
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).
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,613
Messages: 28,158

#13
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.
 

rainer_d

Active Member

Thanks: 4
Messages: 103

#14
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?
;-)
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,613
Messages: 28,158

#15
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.
 

rainer_d

Active Member

Thanks: 4
Messages: 103

#16
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).
 
OP
OP
B

bryn1u

Well-Known Member

Thanks: 9
Messages: 338

#18
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.
 
Top