Virtphp and phpbrew: setting up two different applications with different PHP versions on one server

195 Views Asked by At

I'm a bit confused by virtphp's documentation on Github.

I have one server: CentOS 7. The default PHP version for the server is 7.0.18 (this is aside from phpbrew).

Application #1 needs to run 7.0.18.

Application #2 needs to run 5.3.22.

Both versions are attainable via phpbrew. No problem there.

Using virtphp I've set up two environments: enter image description here

So I can activate, deactivate, no problem.

Say I activate 5.3.22 in a folder. Run

php -v

and it shows 5.3.22. But How to keep that version persistent for that particular application?

Reason being I've been assigned a really oldschool wordpress site that needs to be maintained and have been explicitly told not to upgrade anything related to it: deprecated mysql functions, php version, wordpress version, etc.

If there is something I'm overlooking here, please let me know.

Any and all input is appreciated. Thank you.

1

There are 1 best solutions below

0
On

I think virtphp is not a best choice for that (Maybe you're looking for Docker). Anyway, perhaps adding alias (in ~/.bash_alias) can help you to avoid multiple cmd before running your server :

alias run_app2=“cd {your app folder} && source ~/root/.virtphp/envs/envs-5-3-22-bin/bin/activate && phpbrew use php-5.3.22 && {you run command}”

So you just run run_app2 in terminal and you're good with the right php version.

Hope this help