Welcome! Log In Create A New Profile

Advanced

Re: Installing two versions of PHP-FMP?

Francis Daly
October 11, 2022 06:36PM
On Wed, Oct 05, 2022 at 12:08:34AM +0200, Gilles Ganault wrote:

Hi there,

> I only have shallow experience with nginx.
>
> To migrate an old php5-based application to the latest release which expects
> php7, I'd like to install both versions of PHP-FPM in one nginx server.

php (with php-fpm) is independent of nginx; so the way to install one
or more versions of php is "whatever your operating system wants".

So do that, to end up with (probably) one tcp port listener (or unix
domain socket) for the php5 fastcgi server, plus one for the php7 fastcgi
server. ("fpm" = "fastcgi", in this context.)

> Although I read elsewhere it's a mistake to install the php package instead
> of php-fpm because the former also installs Apacheā€¦ this is what this
> document https://menchomneau.medium.com/how-to-install-multi-php-server-on-ubuntu-20-04-and-nginx-ae63bc87c74b

This, and the link in the parallel reply, show how to run one nginx
process, configured to run two server{} blocks (which means "two host
names"); and one server{} only uses php5 and the other only uses php7.

Depending on the applications involved, that might be the simplest way
to deploy them.

However, there is no reason not to use one server{} block, provided that
you have a way of knowing which requests should go to each fastcgi server.

> So, what's the recommended way to set things up so that nginx can support
> both interpreters and manage two versions of a web app in their respective
> directory?

Within the server{}, each incoming request is handled in one
location{}. Make sure that requests that should be handled by php5 are
handled in a location that does "fastcgi_pass" to the php5 server; and
the other requests are handled in a location that does "fastcgi_pass"
to the php7 server.

That could be something like

location ~ ^/app5/.*\.php {
fastcgi_pass unix:/tmp/php5.sock;
}
location ~ \.php {
fastcgi_pass unix:/tmp/php7.sock;
}

but the extra details for how each application is installed and what it
expects, will matter.

(And that config fragment would need extra supporting config, in order
to be useful.)

Good luck with it,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list -- nginx@nginx.org
To unsubscribe send an email to nginx-leave@nginx.org
Subject Author Posted

Installing two versions of PHP-FMP?

Shohreh October 04, 2022 06:10PM

Re: Installing two versions of PHP-FMP?

Anoop Alias October 04, 2022 11:22PM

Re: Installing two versions of PHP-FMP?

Sergey A. Osokin October 05, 2022 01:30PM

Re: Installing two versions of PHP-FMP?

Francis Daly October 11, 2022 06:36PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 246
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready