Question

Running different versions of PHP in different directories.

Posted March 21, 2020 120 views
PHP

Hello all. I need to run different versions of PHP in different directories. For example in var/www/html I’d need to run the standard PHP 7.x and in var/www/html/xxxx I’d need to run PHP 5.x.

There are quite a few strategies for this described online, and other hosting/vps services directly offering the built-in ability, but after a day of experimenting with these strategies on digitalocean droplets, I’ve found none that have worked on digitalocean droplets.

So, if anyone is running different versions of PHP on different directories in digitalocean, then please, would you share your methods?

Thanks,
Garth

1 comment
  • I was able to achieve this by following a guide posted here.

    I followed that guide exactly on a Digital Ocean Ubuntu LAMP 18.04 droplet, using the .htaccess method mentioned in the guide.

    Thanks for your suggestion KDSys. I have not yet tried PHPBrew.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi @garthkiser,

It is possible to have two different versions of PHP co-installed, but it is probably not worth the pain if you have other options. I would suggest using separate Droplets if you have two applications that require different versions of PHP. That said, there are some tools for working with multiple PHP versions. PHPBrew is probably the easiest and most used. It’s particularly useful for a development environment where you need to switch between versions.

Regards,
KDSys

Submit an Answer