You can run multiple versions of PHP on the same server. This is useful in many cases. For example:
- Testing the same PHP app under multiple PHP versions.
- Running several PHP apps that each requires a different version of PHP
I personally find this very useful to rapidly test apps generated by AppGini under multiple PHP versions.
AppGini is a nocode/lowcode graphical tool for configuring and generating web applications for easily managing data for small businesses, organizations, teams in small/large companies, or even your indvidual projects. Apps created by AppGini support multiple users, are responsive and mobile-friendly, work on LAMP stack for easy installation and wide support, allow importing and exporting of data to CSV, and many more features. A free fully working trial of AppGini can be downloaded from here
end of shameless self-promotion ;)
First, you should follow step 1 of this tutorial
to install multiple versions of PHP. Next, create the below setphp
file, perhaps in your home directory.
Make it executable by running:
chmod +x setphp
Finally, to switch to a specific PHP version:
~/setphp 7.4
This script takes care of setting both PHP-CLI and PHP-FPM (the PHP module for Apache), as well as restarting Apache to apply the changes.