首页 文章

包php5没有安装候选(Ubuntu 16.04)

提问于
浏览
79

当我尝试使用以下代码在Ubuntu 16.04中安装php5时:

sudo apt-get install php5 php5-mcrypt

我收到以下错误:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package php5 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'php5' has no installation candidate

我试过重新安装,但没有帮助 .

我将15.10 Ubuntu更新为16.04后遇到了所有这个错误

7 回答

  • 122

    如果您只想安装PHP,无论它是什么版本,请尝试PHP7

    sudo apt-get install php7.0 php7.0-mcrypt
    
  • 49
    sudo apt-get install php7.0-mysql
    

    对于php7.0适合我

  • 0

    这对我有用 .

    sudo apt-get update
    sudo apt-get install lamp-server^ -y
    

    ;)

  • 31

    目前,我使用的是Ubuntu 16.04 LTS . 在使用Php获取Postgress数据库值时,我也遇到了同样的问题,所以我使用以下命令解决了这个问题 .

    我的PHP版本是7.0,所以我尝试了下面的命令 .

    apt-get install php-pgsql

    Remember to restart Apache .

    /etc/init.d/apache2 restart
    
  • 3

    我最近也有这个问题并使用以下命令解决了它:

    sudo apt install php7.2-cli
    

    php现已安装 . 我正在使用Ubuntu 18.04 .

  • 0

    Ubuntu 16.04标配PHP7,因此没有PHP5软件包

    但是,如果您愿意,可以添加PPA来获取这些包:

    Remove all the stock php packages

    使用 dpkg -l | grep php| awk '{print $2}' |tr "\n" " " 列出已安装的php包,然后使用sudo aptitude清除your_packages_here删除不需要的包,或者如果要直接删除它们,请使用:

    sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
    

    Add the PPA

    sudo add-apt-repository ppa:ondrej/php
    

    Install your PHP Version

    sudo apt-get update
    sudo apt-get install php5.6
    

    你也可以安装php5.6模块..

    Verify your version

    sudo php -v
    

    基于https://askubuntu.com/a/756186/532957(感谢@AhmedJerbi)

  • 0

    您必须在ubuntu 14.04和olders中使用前缀“php5.6-”而不是“php5-”:

    sudo apt-get install php5.6 php5.6-mcrypt
    

相关问题