OT:: Multiple PHP Versions

Home » General » OT:: Multiple PHP Versions
General 13 Comments

Hello,

Been trying to get multiple versions of PHP on a CentOS 7 machine, off and on for the past couple months. I have followed 5 or 6 different howtos but none work. They are very similar and they seems to be done on a fresh install as most do an apache install is the steps. I setup two virtualhosts one for PHP5.6 and one for PHP 7.4. When I create a file with phpinfo, it reports back 5.6.xxx on both sites.

So, I’m wondering if I need to remove the existing PHP version that is included with CentOS? Any suggestions or a better way to do this?

TIA

13 thoughts on - OT:: Multiple PHP Versions

  • You should be using Software Collections to install additional versions:

    https://www.softwarecollections.org/en/about/

    Instead of running PHP within the Apache binary, use a proxy. I suggest learning how to use fcgi. Your VirtualHost could include a directive like this:

    SetHandler “proxy:fcgi://127.0.0.1:9000

    Install rh-php73-php-fpm (for example) with yum to run the proxy service.

  • The general concept is to install the 3rd party package to /opt and use environment variables like path to drive a service to use the custom location for your desired version.

    You might find that someone has packaged the version you desire in the COPR system. I used that for BackupPC 4 before it was available in EPEL.

  • Yes, but you have to think about it’s maintainance status, be it a SCL
    or packages in COPR or elsewhere. If it’s unmaintained you might not want to use it, especially if Software weaknesses might be exploited remotely.

    Regarding the php SCLs by RedHat (which were rebuilt by a CentOS Sig):
    You will not get security updates for php < 7.3. Best Regards, Markus

  • Take a look at Remi Collet’s https://rpms.remirepo.net/. He is the maintainer for the Fedora packages and the SCLs, and very passionate about PHP. As I understand it, he is providing security updates for the 7.4 SCL
    available from there through the end of next year (when upstream PHP drops support).

  • I don’t see it, either. I suggest getting the source for 7.2 or 7.3 and updating it to 7.4. Your contribution to the community would be welcome!

  • While I would prefer to install php 7.4 from SCL, both IUS and Remi’s repositories do carry it. Do you see a reason to choose one over the other bearing in mind I need to have multiple versions installed used by different web apps?

  • –I’m a minor PHP user and 7.3 has been adequate for running WordPress. So I
    haven’t felt pressured to investigate the IUS and Remi offerings.

    I’d suggest downloading both and querying the packages to compare. Use “rpm
    -qplv” to list the files included, and “rpm -qp –scripts” to see what other modifications they’ll make to your system. I always do that on
    “alien” packages to make sure they won’t do anything unexpected to my system. (I so wish Windows packaging was this simple!)

  • If any C7 user has an opinion on whether to use IUS or Remi’s repository for php 7.4, I would love to hear it. As discussed earlier, I am used to SCL but it is not available there.

  • Hello,

    Am 20.08.2022 02:10, schrieb H:

    I have been using Remi’s repo for years and it works great.

    It also has a built-in mechanism to run multiple versions in parallel.

    The only thing you have to look out for is the dedicated paths it uses, such as /opt/remi/php* and /etc/opt/remi.

    Kind regards,
    Steve

  • Thank you for sharing. I will look at his repository.

    By the way, is anyone running php 8.0/8.1 on CentOS 7? Again, it is not available on SCL.