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
November 4, 2013
Chris
PHP, Ubuntu
11

How to install latest PHP 5.4.x on Ubuntu 12.04 LTS (Precise Pangolin)

PreviousNext
php

Disclaimer: Currently 5.5 is the very latest version of PHP, but the common way to install PHP 5.5 has a major disadvantage: It will also install Apache 2.4 or update your Apache 2.2 (standard!) to version 2.4, which will introduce new apache config files, removing current ones (!). No joke. As many apache tutorials teach people to change stuff in /etc/apache2/sites-available/default (which will be removed during Apache 2.4 installation) it might be a bad choice to install PHP 5.5. If you still want to install PHP 5.5, check these articles:

How to install/setup latest version of PHP 5.5 on Debian Wheezy 7.0/7.1/7.2
How to install/setup latest version of PHP 5.5 on Ubuntu 12.04 LTS (Precise Pangolin)

 

And now, let’s install the latest version of PHP 5.4

There’s an excellent and (usually) hassle-free method to install the latest version of PHP 5.4 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-oldstable

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

Check the available version of PHP (the result is self-explaining, the version on the top is the one that will be installed):

apt-cache policy php5

3. Install PHP 5.4.x

sudo apt-get install php5

Check the installed version of PHP (if this does not show 5.4.x please restart your apache)

php5 -v

Please note: The ondrej/php5-oldstable repository (which is used here) provides the very latest version of the PHP 5.4-branch. Usually a version-update 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.
 
[wp_ad_camp_2]
 

To UPDATE from PHP 5.3 to 5.4:

It’s also possible to update from any PHP version to 5.4 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

 

This article was written quite a while ago (10 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] 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 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
  • How to install php-login-one-file on Ubuntu 12.04 LTSHow to install php-login-one-file on Ubuntu 12.04 LTS
  • PHPMyAdmin not found after installation ? Here’s a fix (Ubuntu 12.04) !PHPMyAdmin not found after installation ? Here’s a fix (Ubuntu 12.04) !
PHPphp 5.4Ubuntu
Share this

11 Comments

  • Jill Marci Sybalsky
    March 14, 2016 3:42 am

    Upgraded from PHP 5.3 to 5.4 now every website is BROKEN

    php5 -v
    PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php5/2010052 5+lfs/adodb.so’ – /usr/lib/php5/20100525+lfs/adodb.so: cannot open shared object file: No such file or directory in Unknown on line 0
    PHP 5.4.45-3+deb.sury.org~precise+1 (cli) (built: Jan 7 2016 15:34:33)
    Copyright (c) 1997-2014 The PHP Group
    Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

    HELP now what?!?!

    FYI- apt-cache policy php5
    php5:
    Installed: 5.4.45-3+deb.sury.org~precise+1
    Candidate: 5.4.45-3+deb.sury.org~precise+1
    Version table:
    *** 5.4.45-3+deb.sury.org~precise+1 0
    500 http://ppa.launchpad.net/ondrej/php5-oldstable/ubuntu/ precise/main i386 Packages
    100 /var/lib/dpkg/status
    5.3.10-1ubuntu3.21 0
    500 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main i386 Packages
    500 http://security.ubuntu.com/ubuntu/ precise-security/main i386 Packages
    5.3.10-1ubuntu3 0
    500 http://us.archive.ubuntu.com/ubuntu/ precise/main i386 Packages

    Reply
  • caifo
    July 16, 2015 8:34 pm

    Thanks!!

    Reply
  • Mark
    June 16, 2015 8:32 am

    Thanks for this article. Been searching loads of sites on how to update my PHP to version 5.4. This worked perfect. Keep up the good work!

    Reply
  • Luis Castillo
    May 12, 2015 1:30 pm

    I make all step and now i have php5.4 in my server but apache cannot load sites, i replace old php.ini with the newer version, i use virtualmind. how to fix? or reverse.

    Reply
  • curtismaurand
    April 22, 2015 4:04 pm

    solved most of my problems except it’s missing adodb.so, pam_auth.so and sasl.so.

    Reply
  • Airton
    November 8, 2014 1:29 pm

    It works!

    Thank you so much!

    Reply
  • Emiliano Viada
    September 1, 2014 4:08 pm

    Great article! thanks

    Reply
  • kenrayner
    May 18, 2014 1:45 am

    Thanks so much – lifesaver.

    Reply
  • FGM
    March 6, 2014 9:23 am

    Note that this will not upgrade your extensions, so if – as likely – you are using PEAR/PECL extension like APC, uploadprogress, mongo, redis, xhprof … you will need to also :
    – update the php5-pear package, which will be broken at this point
    – uninstall your PECL extensions and reinstall them : some can be upgraded, but others are at the same version so just doing a “sudo pecl upgrade ” will not work because PECL will not see the PHP version change as an upgrade. Simpler to just uninstall/install again.

    Reply
  • m8in
    December 18, 2013 2:54 pm

    Thank you! This solved my problems ;-)

    Reply

Leave A Comment Cancel reply

hiphop php

Vote for “Hack” for HipHop/HHMV support (future style PHP) in PHPStorm 8

“Hack” will come. And “Hack” will change PHP, definitly. In case you never heard of it, have a look into

hiphop php

HipHop VM reaches 100% green Unit Tests in Laravel, Drupal, Slim, CodeIgniter etc.

In September 2013 the PHP HipHop VM dev team wrote a very interesting article [1] about failing Unit Tests of

php

12 tools for better PHP quality

Nice selection of 12 tools every PHP developer should bookmark. I totally love how the PHP community becomes some kind

php

PHP 5.7 gets refactored core, is 10%-30% faster than PHP 5.5! Wow!

What an announcement! The awesome PHP core guys have refactored the Zend Engine (which drives PHP) and could successfully speed

Meet the developers behind Ableton (14min video)

An excellent short documentation about the developers behind Ableton, the legendary creators of Ableton Live and Push. Without doubt, Live

phpstorm 7.0 php

How to debug code on a remote server (or in vagrant box) with PHPStorm

Please also note: There are several methods to do remote debugging. This is the one that works without any browser

phpstorm-8

PHPStorm 8 (early access version) released – for free

JetBrains have just released an Early Access version of the upcoming PHPStorm 8. In case you never worked with PHPStorm

phpstorm-8

Killer-feature in PHPStorm: Search everywhere

A short but massive productivity improvement: The new “search everywhere” feature in PHPStorm 7.1+! Simply double-tap the SHIFT key and

css3-chrome-font

[Link] Retinafy your Site / Device by Nijiko Yonskai

A simple one-page Gist with all the information you need to make your sites retina-ready: Nijiko Yonskai – Retinafy your

A collection of beautiful ajax loaders / spinners in pure .svg / CSS

No images used, pure svg/css and scaleable. Bookmark now! Brent Jackson‘s ajax spinner / loader library on the project’s demo

1/4

Categories

Search

laracon-2014-eu-amsterdam
Laracon 2013 – Jordi Boggiano: In Depth Composer (47min video)
sass
New features in SASS 3.3 (a talk by SASS-creator Chris Eppstein)
Beautiful, minimal WordPress theme ZUKI by Elmastudio (with 30% discount)
Stressed and unrelaxed while coding ? Try some ultra-deeply-relaxing ASMR audio clips. It will change your life. Seriously.
hiphop php
PHP’s HipHop outperforms PHP 5.5 with Zend OPCache and Nginx by 15-20 times
php
How to install the mcrypt php extension (to use Laravel 4)
git-php-deployment
Extremely simple deployment with PHPloy
Joshua Davis – my hero of Flash – in two excellent interviews (audio, video)
How to show the available version of a package (before doing apt-get install)
nginx php 5.5
[Link] Set up Nginx with PHP 5.5 easily
How to fix the ugly font rendering in Google Chrome
github-logo-octocat
GitHub rolls out .PSD diff and viewing
vagrant
How to copy Vagrant boxes (or duplicate them)
O’Reilly sells EVERY ebook for -50% right now!
js javascript
Push database changes to all clients in real-time (!) with AngularJS and Firebase

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