How do I install different (upgrade or downgrade) PHP version in still supported Ubuntu release?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
224
down vote

favorite
131












I am trying to update to install PHP 5.5, 5.6 or 7.0 in Ubuntu 12.04/14.04/16.04 LTS, and I can only get PHP 5.3.10 for Ubuntu 12.04, PHP 5.5.9 for Ubuntu 14.04 or PHP 7.0.4 for Ubuntu 16.04 using official repositories (using apt-get).



I'm not really sure how to do a manual update – as I need:



  • to play around with the new(est) PHP features

  • to install older PHP version due support in the software









share|improve this question



















  • 1




    if sudo apt-get upgrade Dont upgrade PHP then try sudo apt-get dist-upgrade. For distribution upgrade.
    – Moiz Kiyani
    Oct 12 '13 at 16:19














up vote
224
down vote

favorite
131












I am trying to update to install PHP 5.5, 5.6 or 7.0 in Ubuntu 12.04/14.04/16.04 LTS, and I can only get PHP 5.3.10 for Ubuntu 12.04, PHP 5.5.9 for Ubuntu 14.04 or PHP 7.0.4 for Ubuntu 16.04 using official repositories (using apt-get).



I'm not really sure how to do a manual update – as I need:



  • to play around with the new(est) PHP features

  • to install older PHP version due support in the software









share|improve this question



















  • 1




    if sudo apt-get upgrade Dont upgrade PHP then try sudo apt-get dist-upgrade. For distribution upgrade.
    – Moiz Kiyani
    Oct 12 '13 at 16:19












up vote
224
down vote

favorite
131









up vote
224
down vote

favorite
131






131





I am trying to update to install PHP 5.5, 5.6 or 7.0 in Ubuntu 12.04/14.04/16.04 LTS, and I can only get PHP 5.3.10 for Ubuntu 12.04, PHP 5.5.9 for Ubuntu 14.04 or PHP 7.0.4 for Ubuntu 16.04 using official repositories (using apt-get).



I'm not really sure how to do a manual update – as I need:



  • to play around with the new(est) PHP features

  • to install older PHP version due support in the software









share|improve this question















I am trying to update to install PHP 5.5, 5.6 or 7.0 in Ubuntu 12.04/14.04/16.04 LTS, and I can only get PHP 5.3.10 for Ubuntu 12.04, PHP 5.5.9 for Ubuntu 14.04 or PHP 7.0.4 for Ubuntu 16.04 using official repositories (using apt-get).



I'm not really sure how to do a manual update – as I need:



  • to play around with the new(est) PHP features

  • to install older PHP version due support in the software






ppa php






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 12 '16 at 19:10









oerdnj

6,6282948




6,6282948










asked Mar 2 '12 at 14:45









kavisiegel

1,252399




1,252399







  • 1




    if sudo apt-get upgrade Dont upgrade PHP then try sudo apt-get dist-upgrade. For distribution upgrade.
    – Moiz Kiyani
    Oct 12 '13 at 16:19












  • 1




    if sudo apt-get upgrade Dont upgrade PHP then try sudo apt-get dist-upgrade. For distribution upgrade.
    – Moiz Kiyani
    Oct 12 '13 at 16:19







1




1




if sudo apt-get upgrade Dont upgrade PHP then try sudo apt-get dist-upgrade. For distribution upgrade.
– Moiz Kiyani
Oct 12 '13 at 16:19




if sudo apt-get upgrade Dont upgrade PHP then try sudo apt-get dist-upgrade. For distribution upgrade.
– Moiz Kiyani
Oct 12 '13 at 16:19










2 Answers
2






active

oldest

votes

















up vote
288
down vote



accepted










You could use a PPA to stay up-to-date with PHP or install previous version of PHP (f.e. PHP 5.6 on Ubuntu 16.04 LTS).



The most widely used repositories come from Ondřej Surý, the Debian PHP maintainer:




  • ppa:ondrej/php Launchpad logo (for PHP 5.6/7.0/7.1 co-installable versions, PHP 5.5 is no longer supported)

The php5 compat packages:




  • ppa:ondrej/php5-compat Launchpad logo (for dummy php5 to satisfy dependencies in the old packages)

(Click here for instructions on using PPAs.)



PHP PPAs previously contained Apache 2.4 update. This is no longer a case, you need to add separate Apache 2.4 repository:




  • ppa:ondrej/apache2 Launchpad logo (for Apache 2.4)

If you want use these PPAs, do this:



ppa:ondrej/php Launchpad logo (for PHP 5.6/7.0/7.1)



sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php7.1 # for PHP 7.1
sudo apt-get install php7.0 # for PHP 7.0
sudo apt-get install php5.6 # for PHP 5.6


To switch between installed versions use



sudo update-alternatives --config php


Then you must set Apache to work with right version:



sudo a2dismod php7.1 # unload the current version
sudo a2enmod php5.6 # load the version you need
sudo service apache2 restart # restart webserver to apply


ppa:ondrej/php5-compat Launchpad logo (for php5 compat)



sudo add-apt-repository ppa:ondrej/php
sudo add-apt-repository ppa:ondrej/php5-compat
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5 # this will pull php5.6 package


If you don't have add-apt-repository binary do the following:



sudo apt-get install python-software-properties


Precautions:



  • Are PPA's safe to add to my system and what are some "red flags" to watch out for?

  • Each version of PHP has its own set of modules and php.ini.

PHP 5.4



Prepackaged latest PHP 5.4 now resides in separate PPA:
ppa:ondrej/php5-oldstable Launchpad logo



Please be aware that PHP 5.4 has reached its end of life on 3. September 2015 and it doesn't receive any security updates. It's recommended to migrate to at least PHP 5.6 that will receive security updated till 31. December 2018.






share|improve this answer


















  • 5




    Turns out you gotta run sudo apt-get update first!
    – kavisiegel
    Mar 5 '12 at 21:40






  • 3




    there is the php5-cli package for that!
    – matteosister
    Mar 7 '12 at 21:17






  • 11




    After adding the ppa, you could do: sudo apt-get dist-upgrade
    – matteosister
    Sep 23 '12 at 8:03






  • 2




    After installing the ppa, upgrading php and running php -v, the version information starts with this error message: Failed loading /usr/lib/php5/20090626/xdebug.so: /usr/lib/php5/20090626/xdebug.so: cannot open shared object file: No such file or directory Annoying.
    – systemovich
    Oct 24 '12 at 11:55






  • 3




    Use apt-get install software-properties-common if apt-get install python-software-properties doesn't provide the add-apt-repository command.
    – Meetai.com
    Apr 11 '16 at 3:25

















up vote
3
down vote













It will take some time for PHP 5.4 packages to make their way into Ubuntu, as there are an awful lot of dependency checks to do. Ubuntu 12.04 is now in beta so I doubt they'll upgrade it to PHP 5.4 (although I have no official or inside knowledge of this) -- it probably won't appear until Ubuntu 12.10 in October this year. If you want it sooner than that, you'll either have to find a third-party package or learn to build it yourself from the source code.






share|improve this answer



















    protected by Community♦ Jan 28 '14 at 17:41



    Thank you for your interest in this question.
    Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



    Would you like to answer one of these unanswered questions instead?














    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    288
    down vote



    accepted










    You could use a PPA to stay up-to-date with PHP or install previous version of PHP (f.e. PHP 5.6 on Ubuntu 16.04 LTS).



    The most widely used repositories come from Ondřej Surý, the Debian PHP maintainer:




    • ppa:ondrej/php Launchpad logo (for PHP 5.6/7.0/7.1 co-installable versions, PHP 5.5 is no longer supported)

    The php5 compat packages:




    • ppa:ondrej/php5-compat Launchpad logo (for dummy php5 to satisfy dependencies in the old packages)

    (Click here for instructions on using PPAs.)



    PHP PPAs previously contained Apache 2.4 update. This is no longer a case, you need to add separate Apache 2.4 repository:




    • ppa:ondrej/apache2 Launchpad logo (for Apache 2.4)

    If you want use these PPAs, do this:



    ppa:ondrej/php Launchpad logo (for PHP 5.6/7.0/7.1)



    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install php7.1 # for PHP 7.1
    sudo apt-get install php7.0 # for PHP 7.0
    sudo apt-get install php5.6 # for PHP 5.6


    To switch between installed versions use



    sudo update-alternatives --config php


    Then you must set Apache to work with right version:



    sudo a2dismod php7.1 # unload the current version
    sudo a2enmod php5.6 # load the version you need
    sudo service apache2 restart # restart webserver to apply


    ppa:ondrej/php5-compat Launchpad logo (for php5 compat)



    sudo add-apt-repository ppa:ondrej/php
    sudo add-apt-repository ppa:ondrej/php5-compat
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install php5 # this will pull php5.6 package


    If you don't have add-apt-repository binary do the following:



    sudo apt-get install python-software-properties


    Precautions:



    • Are PPA's safe to add to my system and what are some "red flags" to watch out for?

    • Each version of PHP has its own set of modules and php.ini.

    PHP 5.4



    Prepackaged latest PHP 5.4 now resides in separate PPA:
    ppa:ondrej/php5-oldstable Launchpad logo



    Please be aware that PHP 5.4 has reached its end of life on 3. September 2015 and it doesn't receive any security updates. It's recommended to migrate to at least PHP 5.6 that will receive security updated till 31. December 2018.






    share|improve this answer


















    • 5




      Turns out you gotta run sudo apt-get update first!
      – kavisiegel
      Mar 5 '12 at 21:40






    • 3




      there is the php5-cli package for that!
      – matteosister
      Mar 7 '12 at 21:17






    • 11




      After adding the ppa, you could do: sudo apt-get dist-upgrade
      – matteosister
      Sep 23 '12 at 8:03






    • 2




      After installing the ppa, upgrading php and running php -v, the version information starts with this error message: Failed loading /usr/lib/php5/20090626/xdebug.so: /usr/lib/php5/20090626/xdebug.so: cannot open shared object file: No such file or directory Annoying.
      – systemovich
      Oct 24 '12 at 11:55






    • 3




      Use apt-get install software-properties-common if apt-get install python-software-properties doesn't provide the add-apt-repository command.
      – Meetai.com
      Apr 11 '16 at 3:25














    up vote
    288
    down vote



    accepted










    You could use a PPA to stay up-to-date with PHP or install previous version of PHP (f.e. PHP 5.6 on Ubuntu 16.04 LTS).



    The most widely used repositories come from Ondřej Surý, the Debian PHP maintainer:




    • ppa:ondrej/php Launchpad logo (for PHP 5.6/7.0/7.1 co-installable versions, PHP 5.5 is no longer supported)

    The php5 compat packages:




    • ppa:ondrej/php5-compat Launchpad logo (for dummy php5 to satisfy dependencies in the old packages)

    (Click here for instructions on using PPAs.)



    PHP PPAs previously contained Apache 2.4 update. This is no longer a case, you need to add separate Apache 2.4 repository:




    • ppa:ondrej/apache2 Launchpad logo (for Apache 2.4)

    If you want use these PPAs, do this:



    ppa:ondrej/php Launchpad logo (for PHP 5.6/7.0/7.1)



    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install php7.1 # for PHP 7.1
    sudo apt-get install php7.0 # for PHP 7.0
    sudo apt-get install php5.6 # for PHP 5.6


    To switch between installed versions use



    sudo update-alternatives --config php


    Then you must set Apache to work with right version:



    sudo a2dismod php7.1 # unload the current version
    sudo a2enmod php5.6 # load the version you need
    sudo service apache2 restart # restart webserver to apply


    ppa:ondrej/php5-compat Launchpad logo (for php5 compat)



    sudo add-apt-repository ppa:ondrej/php
    sudo add-apt-repository ppa:ondrej/php5-compat
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install php5 # this will pull php5.6 package


    If you don't have add-apt-repository binary do the following:



    sudo apt-get install python-software-properties


    Precautions:



    • Are PPA's safe to add to my system and what are some "red flags" to watch out for?

    • Each version of PHP has its own set of modules and php.ini.

    PHP 5.4



    Prepackaged latest PHP 5.4 now resides in separate PPA:
    ppa:ondrej/php5-oldstable Launchpad logo



    Please be aware that PHP 5.4 has reached its end of life on 3. September 2015 and it doesn't receive any security updates. It's recommended to migrate to at least PHP 5.6 that will receive security updated till 31. December 2018.






    share|improve this answer


















    • 5




      Turns out you gotta run sudo apt-get update first!
      – kavisiegel
      Mar 5 '12 at 21:40






    • 3




      there is the php5-cli package for that!
      – matteosister
      Mar 7 '12 at 21:17






    • 11




      After adding the ppa, you could do: sudo apt-get dist-upgrade
      – matteosister
      Sep 23 '12 at 8:03






    • 2




      After installing the ppa, upgrading php and running php -v, the version information starts with this error message: Failed loading /usr/lib/php5/20090626/xdebug.so: /usr/lib/php5/20090626/xdebug.so: cannot open shared object file: No such file or directory Annoying.
      – systemovich
      Oct 24 '12 at 11:55






    • 3




      Use apt-get install software-properties-common if apt-get install python-software-properties doesn't provide the add-apt-repository command.
      – Meetai.com
      Apr 11 '16 at 3:25












    up vote
    288
    down vote



    accepted







    up vote
    288
    down vote



    accepted






    You could use a PPA to stay up-to-date with PHP or install previous version of PHP (f.e. PHP 5.6 on Ubuntu 16.04 LTS).



    The most widely used repositories come from Ondřej Surý, the Debian PHP maintainer:




    • ppa:ondrej/php Launchpad logo (for PHP 5.6/7.0/7.1 co-installable versions, PHP 5.5 is no longer supported)

    The php5 compat packages:




    • ppa:ondrej/php5-compat Launchpad logo (for dummy php5 to satisfy dependencies in the old packages)

    (Click here for instructions on using PPAs.)



    PHP PPAs previously contained Apache 2.4 update. This is no longer a case, you need to add separate Apache 2.4 repository:




    • ppa:ondrej/apache2 Launchpad logo (for Apache 2.4)

    If you want use these PPAs, do this:



    ppa:ondrej/php Launchpad logo (for PHP 5.6/7.0/7.1)



    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install php7.1 # for PHP 7.1
    sudo apt-get install php7.0 # for PHP 7.0
    sudo apt-get install php5.6 # for PHP 5.6


    To switch between installed versions use



    sudo update-alternatives --config php


    Then you must set Apache to work with right version:



    sudo a2dismod php7.1 # unload the current version
    sudo a2enmod php5.6 # load the version you need
    sudo service apache2 restart # restart webserver to apply


    ppa:ondrej/php5-compat Launchpad logo (for php5 compat)



    sudo add-apt-repository ppa:ondrej/php
    sudo add-apt-repository ppa:ondrej/php5-compat
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install php5 # this will pull php5.6 package


    If you don't have add-apt-repository binary do the following:



    sudo apt-get install python-software-properties


    Precautions:



    • Are PPA's safe to add to my system and what are some "red flags" to watch out for?

    • Each version of PHP has its own set of modules and php.ini.

    PHP 5.4



    Prepackaged latest PHP 5.4 now resides in separate PPA:
    ppa:ondrej/php5-oldstable Launchpad logo



    Please be aware that PHP 5.4 has reached its end of life on 3. September 2015 and it doesn't receive any security updates. It's recommended to migrate to at least PHP 5.6 that will receive security updated till 31. December 2018.






    share|improve this answer














    You could use a PPA to stay up-to-date with PHP or install previous version of PHP (f.e. PHP 5.6 on Ubuntu 16.04 LTS).



    The most widely used repositories come from Ondřej Surý, the Debian PHP maintainer:




    • ppa:ondrej/php Launchpad logo (for PHP 5.6/7.0/7.1 co-installable versions, PHP 5.5 is no longer supported)

    The php5 compat packages:




    • ppa:ondrej/php5-compat Launchpad logo (for dummy php5 to satisfy dependencies in the old packages)

    (Click here for instructions on using PPAs.)



    PHP PPAs previously contained Apache 2.4 update. This is no longer a case, you need to add separate Apache 2.4 repository:




    • ppa:ondrej/apache2 Launchpad logo (for Apache 2.4)

    If you want use these PPAs, do this:



    ppa:ondrej/php Launchpad logo (for PHP 5.6/7.0/7.1)



    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install php7.1 # for PHP 7.1
    sudo apt-get install php7.0 # for PHP 7.0
    sudo apt-get install php5.6 # for PHP 5.6


    To switch between installed versions use



    sudo update-alternatives --config php


    Then you must set Apache to work with right version:



    sudo a2dismod php7.1 # unload the current version
    sudo a2enmod php5.6 # load the version you need
    sudo service apache2 restart # restart webserver to apply


    ppa:ondrej/php5-compat Launchpad logo (for php5 compat)



    sudo add-apt-repository ppa:ondrej/php
    sudo add-apt-repository ppa:ondrej/php5-compat
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install php5 # this will pull php5.6 package


    If you don't have add-apt-repository binary do the following:



    sudo apt-get install python-software-properties


    Precautions:



    • Are PPA's safe to add to my system and what are some "red flags" to watch out for?

    • Each version of PHP has its own set of modules and php.ini.

    PHP 5.4



    Prepackaged latest PHP 5.4 now resides in separate PPA:
    ppa:ondrej/php5-oldstable Launchpad logo



    Please be aware that PHP 5.4 has reached its end of life on 3. September 2015 and it doesn't receive any security updates. It's recommended to migrate to at least PHP 5.6 that will receive security updated till 31. December 2018.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited May 21 '17 at 18:38


























    community wiki





    22 revs, 11 users 35%
    oerdnj








    • 5




      Turns out you gotta run sudo apt-get update first!
      – kavisiegel
      Mar 5 '12 at 21:40






    • 3




      there is the php5-cli package for that!
      – matteosister
      Mar 7 '12 at 21:17






    • 11




      After adding the ppa, you could do: sudo apt-get dist-upgrade
      – matteosister
      Sep 23 '12 at 8:03






    • 2




      After installing the ppa, upgrading php and running php -v, the version information starts with this error message: Failed loading /usr/lib/php5/20090626/xdebug.so: /usr/lib/php5/20090626/xdebug.so: cannot open shared object file: No such file or directory Annoying.
      – systemovich
      Oct 24 '12 at 11:55






    • 3




      Use apt-get install software-properties-common if apt-get install python-software-properties doesn't provide the add-apt-repository command.
      – Meetai.com
      Apr 11 '16 at 3:25












    • 5




      Turns out you gotta run sudo apt-get update first!
      – kavisiegel
      Mar 5 '12 at 21:40






    • 3




      there is the php5-cli package for that!
      – matteosister
      Mar 7 '12 at 21:17






    • 11




      After adding the ppa, you could do: sudo apt-get dist-upgrade
      – matteosister
      Sep 23 '12 at 8:03






    • 2




      After installing the ppa, upgrading php and running php -v, the version information starts with this error message: Failed loading /usr/lib/php5/20090626/xdebug.so: /usr/lib/php5/20090626/xdebug.so: cannot open shared object file: No such file or directory Annoying.
      – systemovich
      Oct 24 '12 at 11:55






    • 3




      Use apt-get install software-properties-common if apt-get install python-software-properties doesn't provide the add-apt-repository command.
      – Meetai.com
      Apr 11 '16 at 3:25







    5




    5




    Turns out you gotta run sudo apt-get update first!
    – kavisiegel
    Mar 5 '12 at 21:40




    Turns out you gotta run sudo apt-get update first!
    – kavisiegel
    Mar 5 '12 at 21:40




    3




    3




    there is the php5-cli package for that!
    – matteosister
    Mar 7 '12 at 21:17




    there is the php5-cli package for that!
    – matteosister
    Mar 7 '12 at 21:17




    11




    11




    After adding the ppa, you could do: sudo apt-get dist-upgrade
    – matteosister
    Sep 23 '12 at 8:03




    After adding the ppa, you could do: sudo apt-get dist-upgrade
    – matteosister
    Sep 23 '12 at 8:03




    2




    2




    After installing the ppa, upgrading php and running php -v, the version information starts with this error message: Failed loading /usr/lib/php5/20090626/xdebug.so: /usr/lib/php5/20090626/xdebug.so: cannot open shared object file: No such file or directory Annoying.
    – systemovich
    Oct 24 '12 at 11:55




    After installing the ppa, upgrading php and running php -v, the version information starts with this error message: Failed loading /usr/lib/php5/20090626/xdebug.so: /usr/lib/php5/20090626/xdebug.so: cannot open shared object file: No such file or directory Annoying.
    – systemovich
    Oct 24 '12 at 11:55




    3




    3




    Use apt-get install software-properties-common if apt-get install python-software-properties doesn't provide the add-apt-repository command.
    – Meetai.com
    Apr 11 '16 at 3:25




    Use apt-get install software-properties-common if apt-get install python-software-properties doesn't provide the add-apt-repository command.
    – Meetai.com
    Apr 11 '16 at 3:25












    up vote
    3
    down vote













    It will take some time for PHP 5.4 packages to make their way into Ubuntu, as there are an awful lot of dependency checks to do. Ubuntu 12.04 is now in beta so I doubt they'll upgrade it to PHP 5.4 (although I have no official or inside knowledge of this) -- it probably won't appear until Ubuntu 12.10 in October this year. If you want it sooner than that, you'll either have to find a third-party package or learn to build it yourself from the source code.






    share|improve this answer
























      up vote
      3
      down vote













      It will take some time for PHP 5.4 packages to make their way into Ubuntu, as there are an awful lot of dependency checks to do. Ubuntu 12.04 is now in beta so I doubt they'll upgrade it to PHP 5.4 (although I have no official or inside knowledge of this) -- it probably won't appear until Ubuntu 12.10 in October this year. If you want it sooner than that, you'll either have to find a third-party package or learn to build it yourself from the source code.






      share|improve this answer






















        up vote
        3
        down vote










        up vote
        3
        down vote









        It will take some time for PHP 5.4 packages to make their way into Ubuntu, as there are an awful lot of dependency checks to do. Ubuntu 12.04 is now in beta so I doubt they'll upgrade it to PHP 5.4 (although I have no official or inside knowledge of this) -- it probably won't appear until Ubuntu 12.10 in October this year. If you want it sooner than that, you'll either have to find a third-party package or learn to build it yourself from the source code.






        share|improve this answer












        It will take some time for PHP 5.4 packages to make their way into Ubuntu, as there are an awful lot of dependency checks to do. Ubuntu 12.04 is now in beta so I doubt they'll upgrade it to PHP 5.4 (although I have no official or inside knowledge of this) -- it probably won't appear until Ubuntu 12.10 in October this year. If you want it sooner than that, you'll either have to find a third-party package or learn to build it yourself from the source code.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 2 '12 at 14:58









        Mike Scott

        1,58621114




        1,58621114















            protected by Community♦ Jan 28 '14 at 17:41



            Thank you for your interest in this question.
            Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



            Would you like to answer one of these unanswered questions instead?


            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491