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
August 22, 2013
Chris
Linux, PHP
33

How to install / setup PHP 5.5.x on Ubuntu 12.04 LTS

PreviousNext
mod-rewrite-ubuntu-14-04-lts

Please note: This works fine. But this package will also upgrade your apache to version 2.4 which has different config files than apache 2.2 and even deletes stuff, like /etc/apache2/sites-available/default when upgrading. This may result in a loss of your apache settings (vhost, mod_rewrite stuff etc.). Be aware of that ! This shit cost me a full weekend. This affects only upgrades, not fresh installs for sure. Update: This is a known bug (more here), I’ll keep this post updated…

 

How to install

There’s an excellent and (usually) hassle-free method to install the latest version of PHP5 (which is 5.5.3 when i’m writing this) with 3 simple bash commands:

1. Add this package-repository to your system. If Ubuntu says that you need to download a key first, then follow the instructions given in the notice.

sudo add-apt-repository ppa:ondrej/php5

If you get an error message now, then please do an update first and install the python-software-properties, that need to be necessary to add a package repository:

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

Check the installed version of PHP via

php5 -v

Please note: The ondrej/php5 repository (which is used here) provides the very latest version of PHP. Usually the new version of PHP is available a few days after it was been officially released. This is really cool and a big step forward as Ubuntu, Debian, CentOS etc. provide only very old versions by default.

 

To UPDATE from PHP 5.3 / 5.4 to PHP 5.5:

It’s also possible to update from any PHP version to the latest one with exactly the commands above. But, after doing

sudo apt-get install php5

you’ll have to restart the server with

sudo /etc/init.d/apache2 restart

or

sudo service apache2 restart

 

By the way, I’ve also written a tutorial on “How to setup latest version of PHP 5.5 on Debian Wheezy 7.0/7.1/7.2 (and how to fix the GPG key error)“, which is different from this here.

 

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

Random articles

  • 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
  • [Link] Set up Nginx with PHP 5.5 easily[Link] Set up Nginx with PHP 5.5 easily
  • [Link] How to set up HipHop, Nginx and Laravel in Ubuntu 12.04 LTS (in a Vagrant box)[Link] How to set up HipHop, Nginx and Laravel in Ubuntu 12.04 LTS (in a Vagrant box)
  • Generate Vagrant boxes with Laravel, HipHop, Nginx, WordPress, MySQL, MariaDB, MongoDB, RabbitMQ etc. with one clickGenerate Vagrant boxes with Laravel, HipHop, Nginx, WordPress, MySQL, MariaDB, MongoDB, RabbitMQ etc. with one click
  • Install Laravel 4 on Ubuntu 12.04 LTS (a how-to tutorial)Install Laravel 4 on Ubuntu 12.04 LTS (a how-to tutorial)
  • How to install latest PHP 5.4.x on Ubuntu 12.04 LTS (Precise Pangolin)How to install latest PHP 5.4.x on Ubuntu 12.04 LTS (Precise Pangolin)
  • 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 install/setup latest version of PHP 5.5 on Debian Wheezy 7.0/7.1/7.2 (and how to fix the GPG key error)How to install/setup latest version of PHP 5.5 on Debian Wheezy 7.0/7.1/7.2 (and how to fix the GPG key error)
PHPPHP 5.5Ubuntuubuntu 12.04 LTS
Share this

33 Comments

  • srini
    May 15, 2018 1:37 pm

    sudo apt-get install -y php5.5
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package php5.5
    E: Couldn’t find any package by glob ‘php5.5’
    E: Couldn’t find any package by regex ‘php5.5’

    Reply
  • James Parsons
    October 23, 2015 1:24 am

    This didn’t work. Thank the good Lord for Virtual Machine snapshots. :)

    Reply
  • David
    September 25, 2015 4:20 pm

    Thanks a lot for this simple solution.
    I was trying to install symfony 2 which need at least php 5.4 on ubuntu 12 LTS :

    Symfony Installer requires PHP 5.4 version or higher and your system has
    PHP 5.3.10-1ubuntu3.19 version installed.

    To solve this issue, upgrade your PHP installation or install Symfony manually
    executing the following command:

    composer create-project symfony/framework-standard-edition

    Reply
    • davidfoucart
      September 28, 2015 2:01 am

      Finally , this was not working have reinstalled a brand new ubuntu 12.04 LTS

      installation httpd-2.4.16 + php-5.6.13 + symphony-2.7.3
      ——————————————————-
      (Brand new Ubuntu 12.04 LTS
      with kernel : 3.2.0-23-generic-pae)

      1. install apache.
      ——————

      download httpd-2.4.16.tar.gz
      (http://httpd.apache.org/download.cgi#apache24)

      # apt-get install libapr1util-dev
      (needed for apache)

      # tar zxvf httpd-2.4.16.tar.gz
      # cd httpd-2.4.16
      # ./configure –prefix=/usr/local/apache2
      # make
      # make test
      # make install

      test : # /usr/local/apache2/bin/apachectl start
      and test the default ‘It works’ web page
      located in /usr/local/apache2/htdocs

      2. install php. (minimal configuration for symfony)
      —————————————————

      2.1. Pre-requisites
      ————–

      # apt-get install libxml2-dev
      (needed for php)

      download zlib-1.2.8.tar.gz
      (http://zlib.net/zlib-1.2.8.tar.gz)
      (needed for symfony with linux systems)

      # tar zxvf zlib-1.2.8.tar.gz
      # cd zlib-1.2.8
      # ./configure
      # make test
      # make install

      this create libz.so.1.2.8 in /usr/local/lib

      2.2. php-5.6.13 installation
      ———————–

      download php-5.6.13.tar.gz
      (http://fr2.php.net/distributions/php-5.6.13.tar.gz)

      # tar zxvf php-5.6.13.tar.gz
      # cd php-5.6.13
      # ./configure –with-apxs2=/usr/local/apache2/bin/apxs –with-zlib-dir=/usr/local/lib
      # make
      # make test
      # make install

      test : # php -v

      # cd /usr/local/apache2/conf/
      and add

      AddType application/x-httpd-php .php .phtml
      AddType application/x-httpd-php-source .phps

      in httpd.conf file

      test by adding an index.php file with in it
      in /usr/local/apache2/htdocs

      3. symfony 2.7.3 installation and demo test
      ——————————————-

      # apt-get install curl

      modify /usr/local/lib/php.ini, uncomment date.timezone and fix it
      (see http://php.net/date.timezone)
      for example : date.timezone = ‘Europe/Brussels’

      # curl -LsS http://symfony.com/installer -o /usr/local/bin/symfony
      # chmod a+x /usr/local/bin/symfony
      # mkdir /home/your_home/symfony_test
      # chmod 777 /home/your_home/symfony_test
      # exit
      $ cd /home/your_home/symfony_test
      $ php /usr/local/bin/symfony demo
      $ cd symfony_demo
      $ php app/console server:run

      console server:run
      Server running on http://127.0.0.1:8000

      Quit the server with CONTROL-C.

      Reply
  • Chris S
    June 19, 2015 2:18 pm

    I updated my php from 5.10 to 5 but now I get the error message:

    phpMyAdmin – Error

    The mysqli extension is missing. Please check your PHP configuration.

    Any assistance will be much appreciated.

    Reply
  • Lorenzo
    April 21, 2015 11:13 am

    about the orange note at beginning of the article… is it fixed now, right?

    Reply
  • jakob.j
    April 19, 2015 1:52 pm

    Hi,

    I have some trouble: after I added the repository,
    when I do: “apt-get install php5”,
    I get: “php5 is already the newest version.”
    But it’s still PHP 5.3

    Any suggestions? Thanks.
    EDIT: btw I use Ubuntu 10.04

    Reply
  • elia
    August 4, 2014 8:28 am

    followed the instructions… When I do ‘php5 -v’ I still get PHP 5.3.2… help …

    Reply
    • aduchesneau
      February 13, 2015 7:42 pm

      me too. Had any clue?

      Reply
  • HL
    June 26, 2014 10:19 pm

    Great. Just what I needed.

    Reply
  • Lars Müller
    June 16, 2014 11:38 am

    hello, after an Update from 5.3 to 5.5 i get these error:
    Output of config test was:

    apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 2 of /etc/apache2/mods-enabled/fcgid_easyscp.load: Cannot load /usr/lib/apache2/modules/mod_fcgid.so into server: /usr/lib/apache2/modules/mod_fcgid.so: cannot open shared object file: No such file or directory

    the mod_fcgid.so cannot load. How can i fix this?

    Reply
    • Lars Müller
      June 16, 2014 12:21 pm

      i do that…i didn`t find any notice of this error :-/

      Reply
  • société offshore
    February 27, 2014 6:59 pm

    This worked great, thanks a lot – saved me a headache.

    Reply
  • Marvoh
    February 5, 2014 9:10 am

    sudo: add-apt-repository: command not found on ubuntu server 12

    Reply
  • Yasha Podeswa
    February 4, 2014 5:47 pm

    Thanks for the post, very helpful! I’m currently running PHP 5.3.10, and I have also installed:

    php5-pspell
    php5-curl
    php5-gd
    php5-intl
    php5-mysql
    php5-xmlrpc
    php5-ldap

    Will updating to 5.5 with the above method break any of the above? I’d just try myself, but I don’t want to break my production server :)

    Reply
    • Chris
      February 4, 2014 6:02 pm

      Sorry, I cannot answer this :( … But in general you should not update a production server withouth being 99% sure everything runs fine. Make a perfect copy of that server and try out :)

      Reply
      • Yasha Podeswa
        February 5, 2014 7:57 am

        Good call, thanks Chris!

        Reply
  • Ilias
    January 6, 2014 11:25 am

    Thank you very much!

    Reply
  • Nicholas O.
    October 12, 2013 1:19 am

    Hi,

    What if I already have v5.3.6 on my LEMP Ubuntu 12.04?
    Is there a way to remove that completely or with it resolve itself?

    Thanks.

    Reply
    • Chris
      October 15, 2013 3:51 am

      Hey Nicholas, I just tried this out: Works perfectly ! I installed the standard packaged PHP version (5.3.10) in Ubuntu 12.04 LTS and did exactly the stuff written in the above article. You’ll need to restart the server afterwards. Thanks for the interesting idea, I will put this into the article.

      Reply
      • Nicholas O.
        October 17, 2013 5:09 am

        Hi Chris,

        Thanks for coming back. I actually uninstalled v5.3.6 and then used the steps you outlined to add the v5.5 ppa. Good news is it works and I got Zend Opcache (Zend Optimizer+) running. Typical load on my DB is now under 10MB (was about 35MB previously). The Opcode Cache (APC) on v5.3.6 was bringing down my server for some strange reason.

        Anyway, thought be useful if someone running Nginx (instead of Apache) lands on your site.

        Restart server command in terminal (Ubuntu 12.04 LTS)

        1. sudo service nginx restart
        or
        2. sudo /etc/init.d/nginx restart

        Reply
        • Chris
          October 17, 2013 1:45 pm

          Wow, excellent! Btw just to clarify: No need to uninstall anything,
          sudo apt-get install php5
          will update PHP without any problems.

          Reply

Leave A Comment Cancel reply

increase-your-pagespeed-score

Increase your PageSpeed score (10min video with Matt Gaunt)

Compact and clever information for dramatic speed increases. Definitly worth watching. This article was written quite a while ago (9

anti block adblock

Show ads to ad-blockering visitors – with PageFair.com

Interesting news on the dramatically decreasing web ad market: There’s a new service called PageFair that does basically exactly what

gamescom 2014 trailers

GAMESCOM 2014: Awesome Next-Gen ingame graphics

Currently Germany’s biggest conference of the gaming industry is running, and everyday awesome stuff reaches the public. Excellent in-game sequences

phpstorm-github-code-color-syntax-theme

Get Github’s code colors in PHPStorm (2014 style)

I really love the colors on GitHub’s code previews but couldn’t find any themes that copy that in a beautiful

sass

[german video] Modernizing and minimalizing frontend markup code at AutoScout24

As this blog has a lot of german speaking readers I’ll post german stuff from time to time. Sorry for

angular js

Learn AngularJS in 20 (or 90) minutes with Dan Wahlin

Definitly two of the best and most up-to-date short-introductions into AngularJS: Dan Wahlin shows how to build a full little

bash-command-line-tutorial

Best introduction to unix command line / bash ever (by André Augusto Costa Santos)

This article was written quite a while ago (9 years), please keep this in mind when using the information written

offf-2014

Europeans: Get ready for OFFF conference / festival in Barcelona, May 2014

Designers and frontend guys, this is for you: If you live or simply are in western Europe in May 2014,

compress-png

Compress png, jpeg, gif and svg up to 90% with Compressor.io

What a fantastic tool: Compressor.io is a totally free service that let you compress png, jpeg, gif or svg files

mod-rewrite-ubuntu-14-04-lts

How to install / setup PHP 5.5.x on Ubuntu 12.04 LTS

Please note: This works fine. But this package will also upgrade your apache to version 2.4 which has different config

1/4

Categories

Search

phpstorm-8
PHPStorm 8 has just been released
mod-rewrite-ubuntu-14-04-lts
How to enable mod_rewrite in Ubuntu 12.04 LTS
angularjs
Two excellent introductions into AngularJS by Todd Motto
october cms
October CMS, built on top of Laravel, is beautiful, clever and on the way to be the new #1 CMS
css3-chrome-font
[Link] Retinafy your Site / Device by Nijiko Yonskai
php
Must-read PHP blog: PHPweekly.com
php uk conference
Profiling PHP Applications by Bastian Hofmann (video from PHP UK Conference 2014)
8 awesome pure CSS spinner / loader
How to show memory usage (Ubuntu)
battlefield-3-free
Electronic Arts / Origin offers Battlefield 3 for free (limited promo action) !
php
Somebody is writing a compiler for PHP, compiles down to machine code, outperforms HHVM
How to fix the ugly font rendering in Google Chrome
Compare 250+ cloud server plans with Cloud Cost Calculator
This picture shows the icon of blindness
How blind people use websites (video with Sina Bahram, blind accessibility researcher)
[Link] Interesting: Designing a Nuclear Waste Warning Symbol That Will Still Make Sense in 10,000 Years

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”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
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