将Debian wheezy升级PHP 5.4至5.5

14

[已解决]

我有一个安装了php 5.4.18的Debian Wheezy系统。 我想将其升级到5.5.x,但标准过程无法运行。

这是我的/etc/apt/sources.list文件:

# deb cdrom:[Debian GNU/Linux 7.0.0 _Wheezy_ - Official amd64 NETINST Binary-1 20130504-14:43]/ wheezy main
deb http://ftp.pl.debian.org/debian/ wheezy main
deb-src http://ftp.pl.debian.org/debian/ wheezy main

deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main

# wheezy-updates, previously known as 'volatile'
deb http://ftp.pl.debian.org/debian/ wheezy-updates main
deb-src http://ftp.pl.debian.org/debian/ wheezy-updates main

#php 5.5
deb http://packages.dotdeb.org wheezy-php55 all
deb-src http://packages.dotdeb.org wheezy-php55 all

我更新了资源,包括:

apt-get update

并安装了php5

apt-get install php5

但是在 httpd 重启之后,我仍然使用旧的 PHP 版本。

php -v

返回:

root@xxx:/# php -v
PHP 5.4.18 (cli) (built: Aug 19 2013 04:03:40)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

当我搜索 PHP 时

find / -name php5
我只能看到刚安装的文件。
root@xxx:/usr/bin# ls -l php*
lrwxrwxrwx 1 root root      21 Dec 11 00:15 php -> /etc/alternatives/php
-rwxr-xr-x 1 root root 8956912 Nov 17 02:37 php5
root@xxx:/usr/bin# ./php5 -v
PHP 5.5.19-1~dotdeb.1 (cli) (built: Nov 17 2014 01:24:08)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
    with Xdebug v2.2.6, Copyright (c) 2002-2014, by Derick Rethans
root@xxxx:/usr/bin# ./php -v
PHP 5.5.19-1~dotdeb.1 (cli) (built: Nov 17 2014 01:24:08)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
    with Xdebug v2.2.6, Copyright (c) 2002-2014, by Derick Rethans

我的phpinfo显示PHP版本为5.4.18

我做错了什么?

//编辑: 我通过directadmin/custombuild进行了更新。

root@xxxx:/usr/local/directadmin/custombuild# vim options.conf

我改变了这行:

php1_release=5.4
php1_release=5.5

接下来:

root@xxxx:/usr/local/directadmin/custombuild# ./build update_data
# [..]
root@xxxx:/usr/local/directadmin/custombuild# ./build php d
# [..]

现在我有php 5.5.19,我可以使用password_hash()函数;)


使用update-alternatives切换到新版本。请参见此处http://superuser.com/questions/669312/make-a-certain-software-version-the-default-in-ubuntu - Jens A. Koch
谢谢,伙计。只有你的解决方案在我的情况下起作用了。 - bigwolk
1个回答

36
  1. 将这些软件包源添加到您的sources.list文件中:通过

    sudo nano /etc/apt/sources.list

在文件末尾添加以下行(右键粘贴):

deb http://packages.dotdeb.org wheezy-php55 all
deb-src http://packages.dotdeb.org wheezy-php55 all

保存并关闭(CTRL-X,“y”,ENTER)。

  1. 更新:

    sudo apt-get update

现在,您将在更新进度的最后一行收到错误消息。

  1. 现在不可能安装PHP,因为Debian刚刚发生错误,并说这些新源未经验证等等,公钥不可用......我发现这个过程非常不直观,我真的不知道为什么更新PHP如此复杂,但是好吧,就是这样...

方法#1 此错误消息的最后一行包含一个密钥,例如“E9C74FEEA2098A6E”。复制该密钥(通常使用鼠标将字符串标记即可将其复制到剪贴板),然后运行以下命令以验证新的软件包源(并将YOUR key放在此处):

gpg --keyserver packages.dotdeb.org --recv-key  E9C74FEEA2098A6E
gpg -a --export E9C74FEEA2098A6E | sudo apt-key add -

第二种方法(感谢Petr提供此方法!)

wget http://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg
  1. 再次进行更新:

    sudo apt-get update

  2. 安装最新版本的PHP 5:

    sudo apt-get install php5

  3. 检查已安装的PHP 5版本(在重新启动apache之前,phpinfo()仍将显示旧的PHP版本):

    php -v

最后,重新启动apache:

sudo service apache2 restart

顺便提一句,据我所知,在Debian 6上无法安装PHP 5.5(不手动编译源代码的话)。


1
你可能还需要执行:sudo apt-get dist-upgrade。如果它说有一些软件包被保留下来。 - tread
方法#2对我有用。在我的情况下,我保留了这个文件/etc/php5/apache2/php.ini。非常感谢! - JRichardsz

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接