Debian 9:没有安装php5软件包

时间:2017-12-07 08:53:17

标签: php linux debian

我需要安装一些软件包来为VB中运行的Debian 9操作系统中的项目准备工作区。我有指示:

----------------------------------------------------------------------
The following Debian 8 packages are required to run [X-Product]:

sudo apt-get install exim4 ntp pwgen curl php5-dev php-pear pkg-config nmap libzmq3 libzmq3-dev libapache2-mod-php5 apache2 percona-server-server-5.6 php5-cli php5-mysql php5-curl php5-intl daemontools-run oracle-java8-installer ant ruby-compass libtool-bin
----------------------------------------------------------------------

当我运行命令时,我得到以下终端堆栈,

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package php5-cli 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

Package php5-mysql 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

Package php5-curl 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

Package libapache2-mod-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: Unable to locate package php5-dev
E: Unable to locate package libzmq3
E: Package 'libapache2-mod-php5' has no installation candidate
E: Package 'php5-cli' has no installation candidate
E: Package 'php5-mysql' has no installation candidate
E: Package 'php5-curl' has no installation candidate
E: Unable to locate package php5-intl

我在互联网上做了一些研究,接下来做了以下事情,

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

它对我没有任何帮助。我需要解决这个问题?如果你问的话,我对Debian知之甚少

注意:我按照提供的答案中的说明操作,问题仍未解决,因为我无法看到php version

当我运行命令时 sudo apt-get install php5.6

它在终端打印,

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'php5.6-json' for regex 'php5.6'
Note, selecting 'php5.6-common' for regex 'php5.6'
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

要查找PHP版本,

sudo php -v

它在终端打印,

sudo: php: command not found

更多信息,如果我运行它

sudo apt-get install php5-dev I get error E: Unable to locate package php5-dev

但是,命令 sudo apt-get install php-dev成功

命令 dpkg -l | grep php| awk '{print $2}' |tr "\n" " "返回值,

这是否意味着我安装了php7并阻止了其他操作?

dh-php php-cli php-common php-dev php-gd php-pear php-xml php7.0-cli php7.0-common php7.0-dev php7.0-gd php7.0-json php7.0-opcache php7.0-readline php7.0-xml pkg-php-tools

4 个答案:

答案 0 :(得分:3)

打开终端并运行以下命令:

apt-get install apt-transport-https lsb-release ca-certificates

获取gpg密钥:

wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

将新存储库添加到源:

echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list

安装PHP5.6

apt-get update apt-get install php5.6

<强>更新

echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list行的解决方法:

运行此命令,并记下输出:

lsb_release -sc

在您选择的编辑器中打开/etc/apt/sources.list.d/php.list并将其附加到底部:

deb https://packages.sury.org/php/ OUTPUT_FROM_LSC_COMMAND main

答案 1 :(得分:3)

libapache2-mod-php5.6php5-devphp5-mysqlphp5-curl只能安装在debian Wheezy(7),Jessie(8)或Sid上。此外,ondrej / php存储库不提供debian Stretch 的那些包,它只提供<spring:property name="sslType" value="TLSv1.2"/>包。

命令php5.6将安装development module for PHP7

sudo apt-get install php-dev

答案 2 :(得分:2)

Debian 9不包含PHP 5.x(参见https://wiki.debian.org/PHP)。要从ppa安装它,请安装包php5.6并相应地命名其他包(例如libapache2-mod-php5.6而不是libapache2-mod-php5

答案 3 :(得分:1)

我遇到了同样的问题,试图按照php网站上的说明进行操作。

事实证明,在Debian 9上,它非常简单:只需从包名中删除版本。

# apt-get install php-common libapache2-mod-php php-cli

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libapache2-mod-php7.0 php7.0-cli php7.0-common php7.0-json php7.0-opcache
  php7.0-readline
Suggested packages:
  php-pear
The following NEW packages will be installed:
  libapache2-mod-php libapache2-mod-php7.0 php-cli php-common php7.0-cli
  php7.0-common php7.0-json php7.0-opcache php7.0-readline