4

I am on php7 now but I have a legacy program relies on php5 as it is using mysql instead of mysqli.

Can I have php5 installed alongside with php7 and switch them around when either of them is needed?

Run
  • 2,513
  • 10
  • 32
  • 57
  • What about updating your program? Obviously that depends on the complexity of your program. I was able to update mine in a relatively short period of time, but then my program is very simple. – Steve R. May 06 '17 at 01:32
  • @SteveR. im trying to now. It is modx - can't believe this program is worse than wordpress! – Run May 06 '17 at 01:42
  • 1
    You may want to look here: "PHP 7.0 (and 5.6) on Ubuntu" https://lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu Since I do not have this dual configuration, I have no knowledge of how good the advice is. – Steve R. May 06 '17 at 01:45

1 Answers1

5

I know this post has been here for a long time but I would answer anyway.

You can install php5 alongside.

All you need to do is install php5.

After installing it, you would have multiple folders holding the different version of your php version.

  1. First start by adding Ondřej Surý PPA to install different versions of PHP – PHP 5.6, PHP 7.0 and PHP 7.1 on Ubuntu system.

    sudo apt install python-software-properties
    
    sudo add-apt-repository ppa:ondrej/php
    
    ##For Apache Web Server
    sudo apt install php5.6
    

    Now you can install most required PHP modules from the list.

  2. Install PHP Modules

    sudo apt install php5.6-cli php5.6-xml php5.6-mysql 
    
  3. To switch between the versions

    1. First make sure you stop your apache2 service

      sudo service apache2 stop
      sudo a2dismod php7
      
    2. I would suggest you run phpinfo() after the above steps to confirm the version running on your computer, if all went well, you should most likely get an error, as no php file would run.

    3. Enable e.g. php5.6

      sudo a2enmod php5.6
      
    4. Restart your apache2 service

      sudo service apache2 start
      
    5. check php version

      php -v
      
derHugo
  • 3,306
  • 5
  • 30
  • 49
librallaw
  • 51
  • 1
  • 2