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 (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] 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

phpstorm-8

PHPStorm 8 has just been released

The excellent PHP IDE PHPStorm just had a major release these days: Version 8 is out, coming with latest PHP

php

How to install the mcrypt php extension (to use Laravel 4)

When installing Laravel 4 on a fresh Ubuntu or Debian system, you’ll probably get this error message: “Laravel requires the

vagrant

How to setup a (or multiple) server/LAMP-stack inside a virtual machine for local development with Vagrant and PuPHPet

You know this: You need a new server, something to develop on, something to test on, something to put your

php uk conference

PHP Caching Best Practices by Eli White (video from PHP UK Conference 2014)

The title says it all: PHP Caching best practices. This article was written quite a while ago (9 years), please

Disappointed by Watch Dogs’s graphics ? See how it looks with unlocked, hidden settings. Awesome!

When you are interested in 3D and game graphics in general, you probably stumbled upon these excellent and extremely good-looking

Serious hard-to-fix bug in OAuth and OpenID discovered, lots of major sites affected

Just a short notice rather than a real article, full story later (I need to check the facts): Several sources

How to hack time (KUNG FURY promo campaign)

:) Finally, KUNG FURY is out! No need for further words, unless you lived in a cave for the last

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

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

Frontend Ops Conf 2014 – Rebooting Flickr On A Node.js Stack, One Page At A Time (from PHP) by Bertrand Fan

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

1/4

Categories

Search

modern-php
Creator of Slim framework and “PHP – The right way” writes book: “Modern PHP”, available 2015
vagrant
A preinstalled Vagrant box with PHP HipHop / HHVM and Ubuntu 13.10 (Saucy Salamander)
angularjs
Two excellent introductions into AngularJS by Todd Motto
bitdeli git github stats
Get visitor stats for your GitHub repo with BitDeli
october cms
October CMS, built on top of Laravel, is beautiful, clever and on the way to be the new #1 CMS
set up a local virtual machine for development with vagrant and puphpet / puppet (and ubuntu, linux, php, apache, mysql)
A super-simple pre-configured Vagrant box with HipHop, Hack and Hack code examples
Test GZIP compression of your server easily
angular js
Learn AngularJS in 20 (or 90) minutes with Dan Wahlin
phpstorm-8
PHPStorm 8 has just been released
Redesigning Windows 8 – fantastic and clever drafts by Jay Machalani
Install Laravel 4 on Ubuntu 12.04 LTS (a how-to tutorial)
Frontend Ops Conf 2014 – Paul Irish: Delivering The Goods In Under 1000ms (40min video)
sass
[german video] Modernizing and minimalizing frontend markup code at AutoScout24
battlefield-3-free
Electronic Arts / Origin offers Battlefield 3 for free (limited promo action) !
Experimenting with HHVM at Etsy (Link)

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