PHP 从 PHP 7.0.4 升级到 PHP 7.0.8 Ubuntu 16.04 LTS

PHP 从 PHP 7.0.4 升级到 PHP 7.0.8 Ubuntu 16.04 LTS

我必须将 PHP 版本从 PHP 7.0.4 升级到 PHP 7.0.8,以便安装仅在 PHP 版本 7.0.6 或更高版本上支持的第三方软件。

root@A# php -v
PHP 7.0.4-7ubuntu2.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

我已经使用过这个存储库,它没有任何 PHP 版本 7.0.6 或更高版本

sudo add-apt-repository ppa:ondrej/php



    root@Anish:/tmp# apt-get update 
    Hit:1 http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease                                             
    Hit:2 http://in.archive.ubuntu.com/ubuntu xenial InRelease                                                    
    Get:3 http://security.ubuntu.com/ubuntu xenial-security InRelease [94.5 kB]
    Get:4 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease [94.5 kB]        
    Hit:5 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease                           
    Get:6 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [244 kB]
    Get:7 http://in.archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages [240 kB]
    Get:8 http://in.archive.ubuntu.com/ubuntu xenial-up

dates/universe amd64 Packages [140 kB]
Get:9 http://in.archive.ubuntu.com/ubuntu xenial-updates/universe i386 Packages [137 kB]
Get:10 http://in.archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [69.9 kB]
Fetched 1,019 kB in 22s (45.2 kB/s)                              
Reading package lists... Done
root@Anish:/tmp# php -v 
PHP 7.0.4-7ubuntu2.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
root@Anish:/tmp# apt-cache policy php7.0
php7.0:
  Installed: 7.0.8-3+deb.sury.org~xenial+1
  Candidate: 7.0.8-3+deb.sury.org~xenial+1
  Version table:
 *** 7.0.8-3+deb.sury.org~xenial+1 500
        500 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main amd64 Packages
        500 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main i386 Packages
        100 /var/lib/dpkg/status
     7.0.4-7ubuntu2.1 500
        500 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        500 http://in.archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main i386 Packages
     7.0.4-7ubuntu2 500
        500 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        500 http://in.archive.ubuntu.com/ubuntu xenial/main i386 Packages
root@Anish:/tmp# 



root@Anish:/tmp# /etc/alternatives/php -v
PHP 7.0.4-7ubuntu2.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
root@Anish:/tmp# which php 
/usr/bin/php
root@Anish:/tmp# /usr/bin/php -v
PHP 7.0.4-7ubuntu2.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
root@Anish:/tmp# 

答案1

您的系统上安装了多个 PHP,但只有一个具有命令行解释器/usr/bin/php

您需要安装该php7.0-cli软件包以将其替换为软件包存储库中的版本。您不需要它来通过 Web 服务器处理 PHP 网页,但没有它,您就无法运行 php 程序。如果您仍有多个程序安装php,您应该能够使用以下命令选择默认安装:

sudo update-alternatives --config php

相关内容