Report this

What is the reason for this report?

Running different versions of PHP in different directories.

Posted on March 21, 2020

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



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.