简体   繁体   English

在Ubuntu 16.04 Xenial上安装php 5.4

[英]Install php 5.4 on Ubuntu 16.04 Xenial

I want to install php5.4 on Ubuntu 16.04 (Xenial). 我想在Ubuntu 16.04(Xenial)上安装php5.4。 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. 我知道它已经过时但我遇到了一个旧的应用程序,我需要在更新代码之前进行测试才能在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. 并检查用PHP -v,它显示安装了php5.6。

This is the output from php -v: 这是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/ ) (步骤见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? 有没有办法我可以强制安装php5.4而不是让它选择它找到的任何php5包?

I have tried with apt-get install -y php5.4 but that does not work. 我尝试过apt-get install -y php5.4,但这不起作用。

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. 编辑:由于该应用程序将被使用很长时间,我决定将整个应用程序改为php7-ready代码。 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. **编辑:** Scratch我的建议如下。 It doesn't declare the Ubu image in the Vagrantfile. 它不会在Vagrantfile中声明Ubu映像。 Oops. 哎呀。 Like I said, I'm a wee bit wet under the wings in all things *nix. 就像我说的那样,在所有事物中我都有点湿透* 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. 如果你运行vagrant,你可以scotch.ioVagrantfile(github链接)中交换Trusty for Xeny并将其旋转。 It's still on PHP 5.6. 它仍然在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. 我只在linux上工作了一个月左右,因此不确定Ubu版本中的Vagrantfile脚本是如何通用的。 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. 我在Azure中运行Trusty,在Vultr中运行Xeny,在桌面和笔记本电脑上运行本地,并且没有看到有关Web开发人员的任何重大差异。

https://box.scotch.io/ https://box.scotch.io/

https://github.com/scotch-io/scotch-box 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东西

Laravel Installer
Laravel Envoy
Blackfire Profiler

Mailcatcher 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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