Install and switch php version 5.6, 7.3 on ubuntu

Tram Ho

Hi everybody , sure as a php developer, you will do many projects at a time and with many different php versions right? Realizing that installing and switching php version needs to include a guide so that I can reuse quickly, today I will write about the topic of installing and switching multi php version on ubuntu so that you can use it. Save and use offline.

Let’s get started.

1. Install php 5.6 & 7.3

First I will install the PHP version on ubuntu.

Open up your terminal and run the following commands:

Thus, two versions of php 5.6 and 7.3 have been installed and the extentions on the two versions.

Note: Here I install php for apache.

Next comes the php verssion switch.

2. Command switch php version 5.6 => 7.3

To switch the version you need to dismoden the current php version and enmod the desired version of php and restart apache:

3. Command switch PHP version 7.3 => 5.6

Similarly for php 5.6 => 7.3 you use the command:

4. Create shell script file to switch version

Also you can create a shell script file to swith version for convenience:

  • Create swith_php.sh file:

  • Add executable rights for the shell script file:

  • Convert PHP version with command:

Note: You can do the same with other php versions

Refer

  1. https://www.tecmint.com/install-different-php-versions-in-ubuntu/
  2. https://vitux.com/how-to-install-php5-and-php7-on-ubuntu-18-04-lts/

Thank you everyone for watching my article, see you next post ?

Share the news now

Source : Viblo