Logo
  • PHP
    • HipHop / HHVM
    • Modern PHP
    • PHPStorm
    • LAMP
    • Laravel
    • Composer
    • PDO
  • JavaScript
    • node.js
    • AngularJS
  • CSS
    • SASS
    • “CSS4” (CSS level 4)
  • HTML
  • Git
  • LAMP
  • Vagrant
  • UI / UX
  • Architecture of …
  • Off-Topic
With ♥ from Berlin
October 19, 2014
Chris
LAMP, PHP
33

How to setup / install PHP 5.6 on Ubuntu 14.04 LTS

PreviousNext

Ubuntu 14.04 LTS ships with PHP 5.5 by default, but if you want to use PHP 5.6, then it’s just 3 lines on the command line away. Please note that this tutorial is for installing on a fresh and untouched Ubuntu 14.04 LTS, not for updating an existing installation of PHP. This works perfectly on every tested Ubuntu 14.04 LTS.

1. Add PHP 5.6 package sources to your system:

sudo add-apt-repository ppa:ondrej/php5-5.6

and confirm with ENTER. If you get an error here, you need to install python-software-properties first (and then do the line above again):

sudo apt-get update
sudo apt-get install python-software-properties

2. Update

sudo apt-get update

3. Install PHP

sudo apt-get install php5

and confirm with “y” and ENTER. You’ll now already see “PHP 5.6.x” in the scrolling installation logs. To properly check  the installed version of PHP do:

php5 -v

Voila! By the way, this extremely-easy-to-install PHP 5.6 package was created by Ondřej Surý, so consider donating him a beer or a coffee via his donation page.

This article was written quite a while ago (8 years), please keep this in mind when using the information written here. Links, code and commands might be outdated or broken.

Random articles

  • PHP 5.6.0 RC1 is availablePHP 5.6.0 RC1 is available
  • Hochlastseiten mit PHP, MySQL und Apache am Beispiel stern.de (deutscher Artikel)Hochlastseiten mit PHP, MySQL und Apache am Beispiel stern.de (deutscher Artikel)
  • How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 14.04 LTSHow to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 14.04 LTS
  • PHP 5.6 announced, statically typed (!) “new” PHP announced by Facebook devsPHP 5.6 announced, statically typed (!) “new” PHP announced by Facebook devs
  • How to setup a local server (in a virtual machine) with Vagrant in PHPStormHow to setup a local server (in a virtual machine) with Vagrant in PHPStorm
  • How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 12.04 or Debian 7.0/7.1How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 12.04 or Debian 7.0/7.1
  • How to setup a (or multiple) server/LAMP-stack inside a virtual machine for local development with Vagrant and PuPHPetHow to setup a (or multiple) server/LAMP-stack inside a virtual machine for local development with Vagrant and PuPHPet
  • PHPStorm: 42 Tips and Tricks (47min video talk by Mikhail Vink at Dutch PHP Conference 2015)PHPStorm: 42 Tips and Tricks (47min video talk by Mikhail Vink at Dutch PHP Conference 2015)
  • What’s new in PHPStorm 9What’s new in PHPStorm 9
5.6LAMPPHPPHP 5.6
Share this

33 Comments

  • Khayrul
    October 28, 2017 10:04 am

    Remove installed PHP and manually install PHP

    Reply
  • Jeromin
    October 10, 2017 11:42 pm

    Actually the PPA has been renamed and is obsolete. The new one is ppa:ondrej/php
    See https://launchpad.net/~ondrej/+archive/ubuntu/php for reference

    Reply
  • Tim Ng
    June 25, 2017 12:00 pm

    php5 -v

    is this the right command?

    Reply
    • Chris
      June 25, 2017 10:22 pm

      The right command for what ?

      Reply
  • gvanto
    April 27, 2017 6:27 pm

    Thanks very helpful. Btw on Ubuntu 14.04 after I ran “apt-get install python-software-properties” still got error “apt-get-repository Command not found”. Needed to install “apt-get install software-properties-common” … then it worked

    Reply
  • a2htray
    April 26, 2017 3:41 am

    nice blog,

    Reply
  • thức ăn bổ phế
    March 23, 2017 10:12 pm

    I am really impressed with your writing skills and also with the layout on your
    blog. Is this a paid theme or did you modify it yourself?
    Either way keep up the excellent quality writing,
    it’s rare to see a nice blog like this one nowadays.

    Reply
  • mal
    February 13, 2017 4:30 am

    soap does not work? any help

    Reply
  • Joel
    June 23, 2016 2:29 pm

    Worked great, thank you!
    Also, you’ve got the wrong dontation link for Orej, it’s https://donate.sury.org

    Reply
  • Ricardo Augusto Coelho
    June 14, 2016 2:21 pm

    That PPA (ondrej/php5-5.6) is now deprecated. You should use this one instead:
    $ sudo add-apt-repository ppa:ondrej/php

    And then, update and install:
    $ sudo apt-get update
    $ sudo apt-get install php5.6

    Reply
    • anD
      February 17, 2017 12:58 pm

      Yes, please update the ppa to:
      sudo add-apt-repository ppa:ondrej/php

      http://stackoverflow.com/questions/40567133/cannot-add-ppa-ppaondrej-php5-5-6

      Reply
    • Chris
      September 29, 2017 5:59 pm

      Obrigado!

      Reply
  • Mohamed kaptan
    May 25, 2016 3:56 pm

    thanks

    Reply
  • Danilo Nascimento
    May 13, 2016 5:05 am

    Thanks!

    Reply
  • Theodore R. Smith
    April 12, 2016 6:24 pm

    This doesn’t seem to have php-fpm???

    Reply
  • Roman
    March 27, 2016 6:41 pm

    thanks, it worked for ubuntu 14.04

    Reply
  • MewX
    March 17, 2016 5:04 am

    Worked perfectly. But it doesn’t depend on `python-software-properties`.
    The command `apt-get install php5` runs on my ubuntu-15-minimal successfully.

    Reply
  • Gohanzo
    February 19, 2016 12:30 am

    Thanks, it helps a lot ;)

    Reply
  • Vlad Kanash
    January 30, 2016 2:38 pm

    Didn’t help. I get php 5.2 installed.

    Reply
    • Laura Trejo
      May 10, 2016 11:53 pm

      got the same

      $ php -v

      PHP 5.3.10-1ubuntu3.22 with Suhosin-Patch (cli) (built: Apr 20 2016 12:31:15)

      Reply
  • Mr Mackey
    September 18, 2015 10:51 pm

    They went away but was getting these quite a bit earlier, mmmkay:

    Cannot access PPA (https://launchpad.net/api/1.0/~ondrej/+archive/php5-5.69) to get PPA information, please check your internet connection.

    Reply
  • farib
    August 12, 2015 4:04 pm

    I did all this. and it says php5 already installed. i tried to update too. but still php 5.5.9

    Reply
  • Ron
    July 30, 2015 12:14 am

    Hmmm. Received an error on the initial command, then did the
    ‘sudo apt-get update’
    That generated this error:
    …
    Reading package lists… Done
    W: GPG error: http://ppa.launchpad.net trusty Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 4F4EA0AAE5267A6C

    Never had an error on ‘apt-get update’ before. Did 1st command cause this? Then
    ‘sudo apt-get install python-software-properties’ updates nothing.

    Reply
  • tleb
    July 19, 2015 8:43 pm

    Wow. I had done a `apt-get install lamp-server^` and realised it was 5.9. I needed 5.6 (that `foo(…$args)` is quite useful :D) and saw your article, did as instructed, expected everything to break, but no! No Apache configuration change, no need to restart Apache, just refreshed my `phpinfo()` page and the version had changed. Amazing job by the creator of this repo!

    Reply
  • Rohit Arora
    May 23, 2015 7:13 am

    You rock dude

    Reply
  • Bishal Paudel
    May 18, 2015 10:55 am

    Perfect. Thanks!

    Reply
  • Michael
    May 17, 2015 8:47 pm

    Unfortunately doesn’t work on my raspi… any suggestions?

    W: Fehlschlag beim Holen von http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/dists/wheezy/main/source/Sources 404 Not Found
    W: Fehlschlag beim Holen von http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/dists/wheezy/main/binary-armhf/Packages 404 Not Found

    The warnings are (half) in german, but what they say is that the packages could not be found…
    However it is working on my Ubuntu system, therefore i have no idea whats wrong with the raspberry.

    Reply
  • Vincent
    January 5, 2015 8:56 pm

    Fantastic. Worked perfectly. Thanks!

    Reply

Leave A Comment Cancel reply

vagrant

A preinstalled Vagrant box with PHP HipHop / HHVM and Ubuntu 13.10 (Saucy Salamander)

Here’s an excellent downloadable Vagrant box that’s brings you a preinstalled HHVM / HipHop for PHP within a Ubuntu 13.10

php

[Link] Excellent PHP best practices, 2014 style

Excellent post on This interests me: A collection of useful best practices in modern PHP development, like Redirecting the user

atomic-design

An introduction into Atomic Design, a super-clean way to style web applications

A super-interesting talk of Brad Frost at beyond tellerrand 2013, explaining the basics of Atomic Design: What is Atomic Design

composer

The difference between “composer install” and “composer update” – nailed on the head

What a beautiful, direct and clean explaination of the often-confusing difference between composer install and composer update: Beau Simensen (Twitter,

This picture shows the icon of blindness

How blind people use websites (video with Sina Bahram, blind accessibility researcher)

162 million people worldwide are blind or visually impaired at a level that does not allow to read texts. An

php

Redesigning the PHP logo – who wants ?

The current PHP logo is a really lovely one, it is highly accepted and has its own charme, transports a

php

Must-read PHP blog: PHPweekly.com

Probably one of the best ressources for your weekly doze of news from the PHP scene: phpweekly.com simply publishes a

phpstorm 7.0 php

A perfect video tutorial to get started with xdebug in PHPStorm

Laracast just published an excellent short tutorial on how to get install xdebug in a local environment and how to

vagrant

A super-simple Vagrant LAMP stack bootstrap (installable with one command)

As I have to setup servers inside Vagrant quite often, sometimes 10 times per day, I started to use provisioning:

What’s new in PHPStorm 9

PHPStorm 9 has just been released a few days ago, and as a PHP developer you should definitly give it

1/4

Categories

Search

ubuntu-14-04-lts lamp
How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 12.04 or Debian 7.0/7.1
Frontend Ops Conf 2014 – Keynote by Alex Sexton: “Front End Operations”
O’Reilly’s Programming JavaScript Applications by Eric Elliott for free (Early Access release)
laracon-2014-eu-amsterdam
Laracon 2013 – Kapil Verma: Engineering Complex Applications with Laravel 4 (40min video)
phpstorm-8
PHPStorm 8 has just been released
phpstorm-8
A PHPStorm shortcuts cheat sheet (for Windows, Mac OS and Linux)
The New Era of JavaScript (28min conference talk, Jack Franklin, 2013)
hiphop php
[Link] How to set up HipHop, Nginx and Laravel in Ubuntu 12.04 LTS (in a Vagrant box)
hearthbleed-ssl-bug
The SSL Heartbleed bug explained in 30 seconds
Frontend Ops Conf 2014 – Paul Irish: Delivering The Goods In Under 1000ms (40min video)
Experimenting with HHVM at Etsy (Link)
PHPStorm: 42 Tips and Tricks (47min video talk by Mikhail Vink at Dutch PHP Conference 2015)
twig
A 6min video introduction into Twig, the PHP templating engine
php mvc
Preview-release of (my) “php-mvc” project (a simple php mvc barebone)
windows-xp-eol
Windows XP is officially dead from today. Do you know people still using it ? Punch them.

Tags

apache bash centos composer conference coupon CSS debian fonts framework git GitHub hack HHVM HipHop HTML HTML5 IDE JavaScript JS LAMP laravel linux mod_rewrite MVC MySQL Nginx optimization PHP PHP 5.5 PHP 5.6 phpmyadmin PHPStorm security server SSD Ubuntu UI UX vagrant video virtual machine voucher VPS wordpress
Side-Project: Wordle-Solver:
www.wordle-helper.info

Pages

  • Privacy Policy
 
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT