简体   繁体   English

在Ubuntu 14.04上选择php版本(php vs php5)

[英]Choose php version on Ubuntu 14.04 (php vs php5)

Im trying to start some projects on Laravel and Symfony 我试图在Laravel和Symfony上启动一些项目

The issue is the following 问题是以下

When I write on terminal this: 当我在终端上写这:

php -v 的PHP -V

I get this: 我得到这个:

PHP 5.6.11 (cli) (built: Jul 13 2015 09:19:13) PHP 5.6.11(CLI)(建立:2015年7月13日09:19:13)

Copyright (c) 1997-2015 The PHP Group 版权所有(c)1997-2015 The PHP Group

Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies Zend Engine v2.6.0,版权所有(c)1998-2015 Zend Technologies

and when I write this: 当我写这个:

php5 -v php5 -v

I get this: 我得到这个:

PHP Warning: Module 'PDO' already loaded in Unknown on line 0 PHP警告:模块“ PDO”已在第0行的“未知”中加载

PHP 5.5.9-1ubuntu4.11 (cli) (built: Jul 2 2015 15:17:32) PHP 5.5.9-1ubuntu4.11(cli)(内置:2015年7月2日15:17:32)

Copyright (c) 1997-2014 The PHP Group 版权所有(c)1997-2014 The PHP Group

Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies Zend Engine v2.5.0,版权所有(c)1998-2014 Zend Technologies

with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies Zend Technologies的Zend OPcache v7.0.3,版权所有(c)1999-2014

The thing is that I have a few modules in the php 5.6.11 version and all the modules that I have installed are in the 5.5.9 version. 事实是,我在php 5.6.11版本中有一些模块,而我安装的所有模块都在5.5.9版本中。 And for both frameworks I need the modules in the 5.5.9 version but they get the 5.6.11 version. 对于这两个框架,我都需要5.5.9版本的模块,但是它们获得的是5.6.11版本。

English isnt my native language, sorry if I made some mistakes writing this. 英语不是我的母语,对不起,如果我在编写此文件时遇到一些错误。

Did you by any chance compiled one of those versions manually? 您是否有机会手动编译了其中一个版本?

The best option to have all modules for PHP 5.6 is to follow the following guide: 使所有模块都适用于PHP 5.6的最佳选择是遵循以下指南:

http://www.dev-metal.com/install-setup-php-5-6-ubuntu-14-04-lts/ http://www.dev-metal.com/install-setup-php-5-6-ubuntu-14-04-lts/

It uses some repositories from ondrej, which are repositories that maintain different PHP versions for the latest ubuntu releases. 它使用ondrej的一些存储库,这些存储库为最新的ubuntu版本维护不同的PHP版本。

Okay, you could try the following: 好的,您可以尝试以下方法:

apt-get install php5-mcrypt php5-mbstring php5-openssl 

After that you can do the following command (as root): 之后,您可以执行以下命令(以根用户身份):

rm -rf /usr/bin/php && ln -s /usr/bin/php5 /usr/bin/php 

This should link the php command to your php5 command, and you'll have the necessary modules installed. 这应该将php命令链接到您的php5命令,并且您将安装必要的模块。

Finally solved it. 终于解决了。 Installed php version manager "phpbrew" and it allows you to have differents versions of php and it also allows you to manage extensions. 安装了php版本管理器“ phpbrew”,它允许您使用不同版本的php,还可以管理扩展。

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

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