Bug 224409 - Support multiple php version
Summary: Support multiple php version
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Jochen Neumeister
URL: https://forums.freebsd.org/threads/59...
Keywords: feature
Depends on:
Blocks:
 
Reported: 2017-12-17 20:37 UTC by Indeax
Modified: 2020-07-02 11:53 UTC (History)
13 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Indeax 2017-12-17 20:37:18 UTC
Actually, it's not possible to install multiple php versions in an easy way with compiled packages (nor ports). All them use the same binary and config files and there is conflicts on package system.

This can be doable with some changes on compile options and some modifications on init scripts (for php-fpm daemon). A good example is actual debian way to implement it (and extra packages from https://deb.sury.org/). For example:

PHP 5.6
binary: /usr/bin/php56
Config: /etc/php/5.6/{apache2|fpm|cgi}/

PHP 7.0
binary: /usr/bin/php70
Config: /etc/php/7.0/{apache2|fpm|cgi}/

To retain compatibility with old config files and have a principal php version for the system an option could be create a new package/port called "php-select-version", a simple script that detect current installed php versions and let you choose the principal one, then create necessary symlinks on binary and conf directories, something like "alternatives" on debian world (https://wiki.debian.org/DebianAlternatives) but a lot more simple and specific.

Thanks.
Comment 1 Romain Tartière freebsd_committer freebsd_triage 2018-02-13 20:47:17 UTC
mat@ is working on it:
https://lists.freebsd.org/pipermail/freebsd-ports/2018-February/112438.html
Comment 2 Mathieu Arnold freebsd_committer freebsd_triage 2018-02-14 07:55:47 UTC
I am definitively not working on this.
Comment 3 Guido Falsi freebsd_committer freebsd_triage 2018-02-14 08:12:48 UTC
I think there is a misunderstanding here.

FLAVOR support for php means being able to depend on different php versions when building binary packages, so that we can get different flavors of, for example, nextcloud depending on php56, php70 and so on.


This has nothing to do with being able to simultaneously install multiple php versions. You should anyway stick to the one chosen on a single system.

If you really have need for multiple php versions, and are using php-fpm, your best solution is create multiple jails and install each php version in it's own jail, where php-fpm runs. At that point you can redirect the scripts to the correct jails via the web server configuration(which you would need to do anyway also).
Comment 4 Indeax 2018-02-14 08:54:46 UTC
Yes, we can install multiple php versions with jails but this is not easy to maintain when creating multiple user on shared hosting environments where users like to change on several domains from one version of php to another and all of them have different users permissions.

Each jails would have to sync users ids, play nice with each users document root path, etc. and If we want to try to migrate hosting panels like ispconfig, vestacp and others and support multiple php versions on it, it's a lot more complicated.

Sure, it's doable with jails or changes on make.conf file. But it's not a hard task to support different php versions on binary builds in the same freebsd install and, for Freebsd to success on shared hosting environment this is really a must have feature.
Comment 5 Mathieu Arnold freebsd_committer freebsd_triage 2018-02-14 13:00:25 UTC
To be clear, like Guido says, I am working on FLAVORS for php, something that makes it so that for example, a PHP extension, a PEAR library, or a PHP application can have multiple packages, each built with a different version of PHP.

For example, right now all those depend on the default PHP version:

$ make -C devel/pecl-event pretty-flavors-package-names
no flavor: pecl-event-2.3.0
$ make -C devel/pear-Horde_Cache pretty-flavors-package-names
no flavor: pear-Horde_Cache-2.5.5

With flavors, a separate package is built:

$ make -C devel/pecl-event pretty-flavors-package-names
php56: php56-pecl-event-2.3.0
php70: php70-pecl-event-2.3.0
php71: php71-pecl-event-2.3.0
php72: php72-pecl-event-2.3.0
$ make -C devel/pear-Horde_Cache pretty-flavors-package-names
php56: php56-pear-horde-Horde_Cache-2.5.5
php70: php70-pear-horde-Horde_Cache-2.5.5
php71: php71-pear-horde-Horde_Cache-2.5.5
php72: php72-pear-horde-Horde_Cache-2.5.5

It definitively does not mean those can be installed at the same time.
It means that whatever the PHP version you need, there is a package available.
Comment 6 Walter Schwarzenfeld 2018-03-09 16:14:00 UTC
See ports #r463917.
Comment 7 Walter Schwarzenfeld 2018-03-09 16:15:03 UTC
ports r463917
Comment 8 rainer 2018-06-01 08:29:54 UTC
I would love to have multiple versions within multiple php-fpm pools running at the same time.
Comment 9 Jochen Neumeister freebsd_committer freebsd_triage 2018-11-10 19:00:37 UTC
Is there any news here, or can I close here?
Comment 10 Indeax 2018-11-11 20:57:00 UTC
The initial request it's not solved but It don't seem to be anyone interested in solving it. I continue to think that it's a good improvement and in theory (I don't have enough knowledge in the matter) easy to do like it's done in others linux's distributions like debian.

Thanks anyway for your great work with Freebsd.
Comment 11 Jochen Neumeister freebsd_committer freebsd_triage 2018-11-11 21:37:31 UTC
We are not Linux Distri ;-)

Your wish is not so easy to implement. Much would have to be changed here. I keep your request but on my todo list. I can not promise you when it will happen. I'll close here. But your wish is not forgotten, and I think he is good. Please continue to make suggestions. We live on it.
Comment 12 machek 2018-12-14 08:39:33 UTC
You can achieve it with ports

    make PREFIX=/usr/local/php72 PHPBASE=/usr/local/php72 install clean 

this way php 7.2 can be executed by calling php72 and any other php version can be installed on same system
Comment 13 Dave Hayes 2020-01-20 20:24:38 UTC
So I have been able to achieve this with the following code inserted into make.conf:

# PHP Makefile arm twisting follows.
p_PHP_FLAVORS=php71 php72 php73 php74
p_GETFLAVOR=echo $$FLAVOR
p_FLAVOR=${p_GETFLAVOR:sh}

.for port in ${p_PHP_FLAVORS}

# Easy part. If your current directory begins with what's in PHP_ALT, you need these variables
.if ${.CURDIR:M*/ports/*/${port}*}
PREFIX=/usr/local/${port}
PHPBASE=/usr/local/${port}
DISABLE_VULNERABILITIES=yes
.info set by CURDIR: ${.CURDIR} -- sets PREFIX: ${PREFIX} and PHPBASE: ${PHPBASE}
.endif

# Harder part, if we detect the flavor is set up via shell environment, you need these variables
.if ${p_FLAVOR} == ${port}
PREFIX=/usr/local/${port}
PHPBASE=/usr/local/${port}
DISABLE_VULNERABILITIES=yes
.info set by FLAVOR ${p_FLAVOR} -- sets PREFIX: ${PREFIX} and PHPBASE: ${PHPBASE}
.endif

.endfor

So far this has worked well and has enabled running multiple versions of php on the same server. Additionally, if I build any port with a php flavor, it gets put in the right place. I'm not sure what one would do with this to roll it out to users ... so I place this here for those of us expert enough to handle this kind of build (and those googling).