Submitted by marcelorp on Thu, 10/04/2018 - 17:55
I want to run multiple PHP versions on the same server, like PHP 5.4 and PHP 7.2 from remi repo. But now when I create a new server, it was creating in the PHP 5.4 version, but I was select the 7.2 version, on server template option. And if I want to change after the creation, the virtualmin tells me some error, like: This virtual server is using the mod_php or FPM execution mode for PHP, such does not allow per-directory version selection.
How can I run the servers with two different versions of PHP without problems? And run PHP-FPM listening in sock files.
Submitted by andreychek on Thu, 10/04/2018 - 19:28 Comment #1
Howdy -- thanks for contacting us!
Firstly, I'll offer that it's our recommendation to use the SCL repository for installing additional PHP versions. We've seen a number of issues when using other third party repositories. Details for using that are available here:
While it's possible that's related to the issue you're seeing if your packages are from REMI, let's start here... what output do you see if you go into System Settings -> Re-Check Config?
Also, if you go into Server Configuration -> Website Options for a domain where you're seeing this problem, what PHP Execution Mode is it configured to use?
Submitted by marcelorp on Fri, 10/05/2018 - 07:55 Comment #2
Here is the output:
The following PHP versions are available : 5.4.45 (/bin/php54-cgi), 7.2.10 (/bin/php72-cgi) PHP-FPM support is available on this system.
And in the server configuration:
PHP script execution mode: FPM (run as virtual server owner) PHP versions installed: 5.4.45, 7.2.10
But I will try again with SCL repo...is there another repo recommended to keep my system updated? I use this repos: (can you tell me if I'm using wrong repo, please):
Submitted by andreychek on Fri, 10/05/2018 - 08:49 Comment #3
I'll respond to your repo question first --
We highly recommend against using any third party packages, and always using your distro's packages where ever possible.
We've seen a number of issues arise when using packages from third parties... the stability isn't the same as when using the standard distro packages.
One of the biggest benefits of CentOS is that it's stable, and it's supported for a long time. However, if the distro packages are replaced by those in third party repositories, you're not really using CentOS anymore so much as you're using those third party repositories, and you miss out on that stability and testing.
We get it though, by CentOS being stable, and using those same packages over the course of years, after awhile the packages can feel older.
CentOS does provide bugfixes and security fixes to all those packages, so you shouldn't be running into any problems with the CentOS packages.
However, if the age of the packages is a big concern for you, you might consider a different distribution that has more regular releases and newer packages.
Ubuntu, for example, comes out with a new LTS version every 2 years. Debian isn't on as regular a schedule, but does have reasonably frequent releases. Those distributions both offer in-place upgrades.
Submitted by andreychek on Fri, 10/05/2018 - 08:49 Comment #4
As far as changing the PHP versions -- what if you change your PHP Execution Mode to FCGID. Do you run into any issues in doing that? And if not, once it's using FCGID, are you then able to select the PHP version you're after?
Submitted by marcelorp on Fri, 10/05/2018 - 11:57 Comment #5
I understand about CentOS, and I dont really need this repo, because I prefer more stable than more updated. So I will do a fresh install of Virtualmin with only Core repo and SCL for multiple PHP. Can you see my other issue about Nginx and PHP-FPM default config template?
Submitted by andreychek on Fri, 10/05/2018 - 12:28 Comment #6
I'm hoping Jamie will be able to help us out with your other request, he's a bit more familiar with the workings of Nginx. What you described might possibly be a bug, though he would know for sure.
Submitted by marcelorp on Fri, 10/05/2018 - 18:56 Comment #7
Thanks for the reply. I have made a fresh install and reinstall virtualmin to get a clean OS. Here is the output now.
The following PHP versions are available : 5.6.25 (/opt/rh/rh-php56/root/usr/bin/php-cgi), 7.0.27 (/opt/rh/rh-php70/root/usr/bin/php-cgi), 7.1.8 (/opt/rh/rh-php71/root/usr/bin/php-cgi) PHP-FPM support was not detected : No FPM configuration directory found.
How can I work with diferent types of PHP-FPM? or that is not possible?
Submitted by marcelorp on Fri, 10/05/2018 - 19:12 Comment #8
I guess is not possible to run different versions of PHP-FPM on virtualmin, I see that is a feature on TODO list. So I will use just one version of PHP now, I really don't need the other version, and in future (when have this feature) I get another PHP version just for compatibility reason.
Submitted by andreychek on Fri, 10/05/2018 - 22:12 Comment #9
Sorry that you ended up doing a complete reinstall to figure that out, though I really do think you'll end up with a more stable system because of it.
I couldn't recall whether PHP-FPM supported switching PHP yet, figuring Jamie would chime in with that info, but it sounds like you've figured that all out already!
But yeah now that you have a clean system, doing the additional PHP versions using the SCL repo should work wonderfully... and if you need any additional PHP versions for a given domain, you can just use CGI or FCGID rather than PHP-FPM.
I use FCGID/CGI on my own personal servers for that flexibility.
Submitted by marcelorp on Sun, 10/07/2018 - 10:13 Comment #10
Can you explain me what is the difference between FCGID and PHP-FPM?
Submitted by andreychek on Sun, 10/07/2018 - 10:36 Comment #11
There's details on the changes from FCGID to PHP-FPM described at the top of the page here in the "What is PHP-FPM?" section:
PHP-FPM is a newer way of doing things, but note that FCGID works just fine and quite a few folks continue to use that mode (including myself).
If you have additional questions that page doesn't answer though feel free to let us know!
Submitted by denisr on Sun, 10/07/2018 - 11:09 Comment #12
andreychek, FCGid is not compatible with Opcache and APCu like FPM, it will use separate cache for different requests, and Opcache need to create cache more frequently. FPM is the only way to use them proper, after mod-php, if you need multiuser support.
Submitted by marcelorp on Thu, 10/11/2018 - 05:40 Comment #13
Submitted by jmunjr on Wed, 10/21/2020 - 05:21 Comment #14
Hi, I am setting up a new server, Centos 7.7, and want to add PHP 5.6, but 5.6 is no longer available via Yum in the SCL repo as far as I can tell. Any recommendations to get 5.6 added and working? I do want the SCL version. Thank you.
EDIT: I managed to manually create a repo pointing to PHP56 in the SCL Vault and installed it that way so it is working now.