简体   繁体   中英

Install php 5.4 on Ubuntu 16.04 Xenial

I want to install php5.4 on Ubuntu 16.04 (Xenial). I know it's obsolete but I came across an old application which I need test before updating the code to be compatible on php7.

When I do the following:

apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php5-oldstable
sudo apt-get update
sudo apt-get install -y php5

and check with php -v, it shows php5.6 installed.

This is the output from php -v:

PHP 5.6.28-1+deb.sury.org~xenial+1 (cli) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.0rc1, Copyright (c) 2002-2016, by Derick Rethans

(Steps followed as at http://tecadmin.net/install-php5-on-ubuntu/ )

Is there a way I can force php5.4 to be installed instead of letting it chose whatever php5 package it finds?

I have tried with apt-get install -y php5.4 but that does not work.

Edit: Since the app was going to be used for a long time, I decided to change the whole application to php7-ready code instead. If anyone else wants to do this, be careful to test the application on different browsers and also on the OS you will be hosting the application (very important!). Took me some time but I guess it's worth it in the long run! Thanks for your help!

**EDIT:**Scratch My suggestion below. It doesn't declare the Ubu image in the Vagrantfile. Oops. Like I said, I'm a wee bit wet under the wings in all things *nix.

I'll still leave just in case it causes you to think of something.


If you run vagrant, you might be able to swap Trusty for Xeny in the scotch.io box Vagrantfile (github link) and spin it up. It's still on PHP 5.6. I've only been on linux for a month or so, so not sure how universal Vagrantfile scripts are across Ubu versions. I'm running Trusty in Azure and Xeny in Vultr and locally on desktop and laptop and haven't seen any big differences regarding web dev stuff.

https://box.scotch.io/

https://github.com/scotch-io/scotch-box

git clone https://github.com/scotch-io/scotch-box.git my-project

Features

Server Stuff

Ubuntu 14.04 LTS (Trusty Tahr)
PHP 5.6
Ruby 2.2.x
Vim
Git
cURL
GD and Imagick
Composer
Beanstalkd
Node
NPM
Mcrypt

Database Stuff

MySQL
PostreSQL
SQLite
MongoDB

Caching Stuff

Redis
Memcache and Memcached

Node Stuff

Grunt
Bower
Yeoman
Gulp
Browsersync
PM2

Laravel Stuff

Laravel Installer
Laravel Envoy
Blackfire Profiler

Mailcatcher

First: `vagrant ssh`
Run: `mailcatcher --http-ip=0.0.0.0`
Then visit: http://192.168.33.10:1080

Other Useful Stuff

WP-CLI
No Internet connection required
PHP Errors turned on
No Internet connection required
Laravel and WordPress ready
Operating System agnostic

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM