Support for multiple PHP versions when using PHP-FPM and Nginx

Unsure whether this is a bug report or a feature request. The comment here suggest that it is a known limitation that this doesn't work with the Nginx bundle and this suggests that this is a feature request.

I'm on Ubuntu 20.04 LTS, Virtualmin 6.11, Webmin 1.954, fresh install.

virtualmin check-config tells me the following:

The following PHP versions are available : 5.6.40 (/bin/php5.6), 7.0.33 (/bin/php7.0), 7.1.33 (/bin/php7.1), 7.2.33 (/bin/php7.2), 7.3.21 (/bin/php7.3), 7.4.9 (/bin/php-cgi7.4)

The following PHP execution modes are available : fcgid fpm

The following PHP-FPM versions are available on this system : 5.6.40 (php5.6-fpm) 7.0.33 (php7.0-fpm) 7.1.33 (php7.1-fpm) 7.2.33 (php7.2-fpm) 7.3.21 (php7.3-fpm) 7.4.3 (php7.4-fpm)

Accessing the Server Configuration -> PHP Versions and trying to change the PHP version yields the following message:

Failed to save PHP versions : The PHP version cannot be changed when in FPM mode.

It won't be long before PHP 8 is released and I'd like to be able to offer PHP 8 on select virtual servers via PHP-FPM too.

While this is not possible to do via Virtualmin in the time of writing, I'd appreciate any info on how to properly do this manually as well.

Status: 
Closed (fixed)

Comments

Ilia's picture
Submitted by Ilia on Mon, 08/10/2020 - 14:17

Hi,

That is correct, and multiple FPM versions aren’t supported under Nginx yet.

While this is not possible, is there a safe way (in terms of not breaking stuff in Virtualmin) to upgrade virtualhosts (individually or all at once) to a new PHP version?

I imagine that moving the pools from /etc/php/7.4/fpm/pool.d/ to /etc/php/8.0/fpm/pool.d/ would be sufficient by itself, but how do I ensure that Virtualmin picks up the newest version when creating new hosts?

Ilia's picture
Submitted by Ilia on Tue, 08/11/2020 - 07:52

Assigned: Unassigned »

While this is not possible, is there a safe way (in terms of not breaking stuff in Virtualmin) to upgrade virtualhosts (individually or all at once) to a new PHP version?

Off-hand, I am not sure about the exact way of doing it. In addition to pools, I would also have a look at /etc/webmin/virtual-server/domains files. There might be something else.

If you are not a developer, I wouldn't worry about PHP 8.0. There will be no practical benefit of installing it right after release. It will take many years for other apps to migrate and utilize its new features.

Jamie, could you comment on that? Where is the problem of changing PHP version with Nginx lies?

The best way to upgrade PHP versions would be to install the new package, then use the API command :

virtualmin modify-web --domain example.com --php-version 7.4

on each domain to switch the version.

Thank you for the suggestion, Jamie, but this doesn't work.

I tried changing a domains PHP version like you suggested and this was the result:

root@serv4:# virtualmin modify-web --domain example.net --php-version 7.3
Updating server example.net ..
Error: The PHP version cannot be changed when in FPM mode
Error
-----
The PHP version cannot be changed when in FPM mode
-----

I'm unsure whether this is actually tied up on Nginx per say, but it seems like you are effectively locked to the version of PHP you installed.

Yes - we don't yet support changing the PHP version under Nginx directly. However, you could switch to fcgid mode and then switch back again, which should pick up the new FPM version :

virtualmin modify-web --domain example.net --mode fcgid
virtualmin modify-web --domain example.net --mode fpm
Ilia's picture
Submitted by Ilia on Mon, 08/17/2020 - 08:12

Does the latter Jamie's solution work for you @repox? When I tried it, it didn't work for me. if so, I assume it's a bug.

No, this didn't work for me either. The version just stays effectively the same. I agree that this seems more like a bug than a feature request, but as mentioned in OP, it seems that the lacking feature seems known and thus just is a missing feature.

But this effectively renders the LEMP bundle for Virtualmin problematic.

I recently installed the virtualmin LEMP-bundle, to check how far the support is currently. I also wanted to use different php-versions, so I configured the fpm-pool manually (copied from another server where I don't use virtualmin), so maybe this is helpful to others, too. I dropped a new file into /etc/php/7.4/fpm/pool.d/USERNAME.conf:

[USERNAME]
prefix = /home/$pool
user = $pool
group = $pool
listen = /run/php/php7.4-fpm-$pool.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.status_path = /fpm-status
ping.path = /fpm-ping
env[TMP] = /home/$pool/tmp
env[TMPDIR] = /home/$pool/tmp
env[TEMP] = /home/$pool/tmp
php_value[upload_tmp_dir] = /home/$pool/tmp
php_value[session.save_path]= /home/$pool/tmp

(replacing the first line "[USERNAME]" with the actual username of this vhost, and the "listen="-line for other php versions) I then replaced the fastcgi_pass-line in the /etc/nginx/sites-available/.conf with

fastcgi_pass unix:/run/php/php7.4-fpm-USERNAME.sock;

It is even possible to start a corresponding pool in multiple php-versions, and switch them just by adjusting the fastcgi_pass-line. Or you can use different php-versions in different directories by having different fastcgi_pass-lines in different -sections in nginx-config.

The real correct fix here is for us to support multiple PHP versions under Nginx, but that's still being worked on ..

Ok, this has been implemented, and will be included in our next release of the Nginx plugin.

So, this issue, which has been marked as fixed, but still pending, is closing to being pending for a year soon.

What is the actual status of this issue and has this been relased?

This has been fixed for a several releases now.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.