Update PPA For PHP, Change PHP CLI Version

BEWARE! THIS WOULD MAKE YOUR LOCALHOST NOT WORKING LIKE WEB APP, PHPMYADMIN, ETC. NEED TO BACKUP YOUR DATA FIRST!

I need to update the PPA for php from ppa:ondrej/php5-5.6 to ppa:ondrej/php because the earlier ppa already deprecated. Here is the step for PPA migration to ppa:ondrej php.

  1. Add the new repository ppa:ondrej/php
  2. Update the system
  3. You need to install new libapache2-mod-phpX.Y packages and then disable the old php5, and enable new versioned module, f.e. for PHP 5.6:

    The result:

    Disable old php5:

    Enable php5.6 modules:

    Restart apache2 service
  4. uninstall old php5 packages (optional)

     
  5. add ppa:ondrej/php5-compat that provide thin layer of compatibility packages that map php5-<foo> to php5.6-<foo> for main php5* packages:

    Update:

    Dist Upgrade:

    Check the php5 packages remaining:

    Check the new php version:

    ‘deprecated’ text is already removed!
  6. Install the php5-* equivalent packages

    For phpmyadmin installation steps, please follow it here. I found a few packages can’t be installed like php-ps, php-sqlite and php-xsl

    That is not OVER YET! phpmyadmin DON’T WORK. When I open it on my browser: http://localhost/phpmyadmin/index.php, I got this error:

    NEED TO FIND THE SOLUTION HERE!
    I followed this askubuntu but the error still persist! When I did

    I got the another error:

    I dont find mbstring extension on my php.ini file although I installed repeatedly (also installed php7.0-mbstring)
    I got a weird php version on my terminal (php cli). On my apache2 webserver (http://localhost/info.php), I got PHP Version 5.6.25-2+deb.sury.org~trusty+1. but when I checked on terminal, I got php 7.0

    Here is the solution to downgrade php cli to version 5.6 (How can I downgrade from PHP 7 to PHP 5.6 on Ubuntu 16.04?):

    OK. SOLVED!! through this askubuntu (Installing PHP 5.6 on Xenial (16.04)), I should install php5.6-mbstring instead of just php-mbstring. Then dont forget to restart apache webserver. Now phpmyadmin is back to work.
  7. Try to use php5.5 (ONLY DO THIS IF I WANT TO TRY AND SHIFT TO DIFFERENT PHP VERSION, IN THIS CASE PHP5.5)
    Currently I used php5.6. (php 5.6.26-1)apache2-php5-6In order to use php5.5, I need to disable the apache2 module for php5.6 first

    Then restart apache

    Then enable the php5.5.

    Here I got an error “Module php5.5 does not exist!” because I haven’t install the apache2 module for php5.5. Install the module

    Restart apache! then enable php5.5 module

    When I refreshed the phpinfo, now I’m using php5.5 (php 5.5.38-3+deb.sury.org~trusty+1)apache2-php5-5I also need to change the php cli on my terminal. It still use php5.6

    to shift to another php version, use like this:

    Here is my php cli version

    I need to install some php modules

    I use explicitly ‘php5.5-xsl’ instead of just ‘php-xsl’ or I got this error

    A few more packages need to be installed, like mbstring, mysqli and mcrypt to make phpmyadmin working!

    DONT FORGET TO RESTART APACHE THEN

    TO MOVE BACK TO PHP 5.6, DO THIS

    FOR PHP CLI

    I found something useful to use different php version on the linux terminal like this

    the default php version now is php5.6 that showed the same result!
    DON’T FORGET TO CONFIGURE PHP SETTING:
    a. type :

    b. edit php setting like :

    c. restart apache :

    d. Check the value in http://localhost/info.php

    It’d be same if I want to use PHP 7 (php7.0). First deactivate my default php5.6

    Then restart apache2 as recommended

    Enable php 7 (here is php7.0)

    Then restart the apache2 server again

    Check the current php version in http://localhost/info.phpIf I need to install more php7.0 extension like mysqli extension is needed by phpmyadmin, do like this:

    don’t forget to restart apache server!
    To change the PHP setting, pls do like this:

    Modify the php.ini file:

    Then restart apache server!

  8. Install xdebug for php5.6
    Somehow I didn’t find xdebug installed for php 5.6. When I opened http://localhost/info.php, I couldn’t find xdebug. After some tries, I have to install it manually with ‘sudo apt-get install php5.6-xdebug’.
    To write the xdebug setting, No need to write it in ‘/etc/php/5.6/apache2/php.ini’ but write it in ‘/etc/php/5.6/apache2/conf.d/20-xdebug.ini’.

    Here is the setting (would use it with kcachegrind):

    Dont forget to restart apache after writing the setting.
    The setting means I can only use xdebug with a trigger like this: http://localhost/works/thefootnotes/?XDEBUG_PROFILE=1
    The xdebug output would be written in ‘/media/data/MASTER/php/cachegrind/’ directory. Use KCacheGrind to view the output

  9. Next time if I want to use and install php 7 along side php 5.6, I can read these tutorials:
    PHP 7.0 (and 5.6) on Ubuntu
    Installing PHP 5.6.x and 7.0.x with Ubuntu 14.04 and Virtualmin 5.0gpl using a PPA
  10. SOLUTION FOR THE ERROR

    Ref: https://askubuntu.com/questions/723775/cannot-uninstall-php-memcache-using-terminal
    SO remove the files like this then update:

     

  11. Install PHP 7.1 and enable it:

    Check the current php version on the teminal:

    BUT I GOT A FAIL WHEN TRYING TO RESTART APACHE2 SERVICE:

    SOLUTION: I NEED TO STOP NGINX SERVICE FIRST:

    ALSO CHECK THE PHP VERSION ON THE BROWSER: http://localhost/info.php.
    I also need to install a few php7.1 extension needed like zip extension (ref: https://laracasts.com/discuss/channels/laravel/zip-php-extension-problem-in-ubuntu-php7):

    DON’T FORGET TO CONFIGURE PHP SETTING:
    a. type :

    b. edit php setting like :

    c. restart apache :

    d. Check the value in http://localhost/info.php

     

Leave a Reply

Your email address will not be published. Required fields are marked *