php 无法找到包 libapache2-mod-php7

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38815245/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 01:44:16  来源:igfitidea点击:

Unable to locate package libapache2-mod-php7

phpubuntuinstallation

提问by Nishan Rai

I tried installing php in ubuntu 16.04 using following command:

我尝试使用以下命令在 ubuntu 16.04 中安装 php:

sudo apt-get install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi  php7.0 libapache2-mod-php7

but it says

但它说

Unable to locate package libapache2-mod-php7

无法找到包 libapache2-mod-php7

Should I skip this or install by an alternative way?

我应该跳过这个还是通过其他方式安装?

回答by rinSer

The name of the package is libapache2-mod-php7.0Try again by having that .0at the end and it should work.

包的名称是libapache2-mod-php7.0Try again 把它.0放在最后,它应该可以工作。

回答by James Graham

On Ubuntu 18.04, I had to add the repository below first. Once the repo was added I was able to install the php7.x items.

在 Ubuntu 18.04 上,我必须先添加下面的存储库。添加 repo 后,我就可以安装 php7.x 项目。

sudo add-apt-repository ppa:ondrej/php

Source: https://websiteforstudents.com/apache2-with-php-7-1-support-on-ubuntu-18-04-lts-beta-server/

来源:https: //websiteforstudents.com/apache2-with-php-7-1-support-on-ubuntu-18-04-lts-beta-server/

回答by Bojan Kseneman

If you are using Ubuntu 17.04/17.10 or above use php7.1 instead of 7.0 since it is no longer available.

如果您使用的是 Ubuntu 17.04/17.10 或更高版本,请使用 php7.1 而不是 7.0,因为它不再可用。

sudo apt-get install php7.1

回答by user1946891

At the time of the post Ubuntu 16.04 was one of the newer versions and as such the packages changed to php7.0 but as time goes on it will be 7.1 to 7.2 etc... and I don't have the time to figure out what was the latest package and I'm not dependent on a specific version. So if you want the latest version of packages to install without having to know the correct version number just drop the version number and the latest applicable to the distribution you are using will be installed. In my case I was using Ubuntu 17.10 and the php version is different so I used the following command line to get the latest.

在发布 Ubuntu 16.04 是较新版本之一,因此软件包更改为 php7.0,但随着时间的推移它将是 7.1 到 7.2 等等......我没有时间弄清楚最新的软件包是什么,我不依赖于特定版本。因此,如果您希望安装最新版本的软件包而不必知道正确的版本号,只需删除版本号,即可安装适用于您正在使用的发行版的最新版本。就我而言,我使用的是 Ubuntu 17.10 并且 php 版本不同,因此我使用以下命令行获取最新版本。

sudo apt-get install apache2 php-mysql libapache2-mod-php mysql-server

It installed php 7.1 and all of the correct dependencies.

它安装了 php 7.1 和所有正确的依赖项。

So if you don't require a specific version but just want the latest that works with the distribution drop the version number and use the command line above.

因此,如果您不需要特定版本,而只想要与发行版配合使用的最新版本,请删除版本号并使用上面的命令行。

回答by Elias Riedel G?rding

It is likely the case that your local package index is not updated; try

很可能是你的本地包索引没有更新;尝试

sudo apt-get update

and then run the previous command again.

然后再次运行之前的命令。

As an aside, there is now a program aptthat is supposedly more user-friendly than apt-get, apt-cacheetc. (see this question on Ask Ubuntu). So your commands could have been replaced by

顺便说一句,现在有一个计划apt就是所谓更人性化的比apt-getapt-cache等等(参见上问Ubuntu的这个问题)。所以你的命令可以被替换为

sudo apt update
sudo apt install <the packages>

to get a slightly nicer user interface.

以获得更好的用户界面。

Probably this question would have been better suited to the Ask Ubuntucommunity.

可能这个问题更适合Ask Ubuntu社区。

回答by user7473484

Apache server can't start because libapache2-mod-php7.0 is not installed: by default aptitude or apt install php7.0-common version 7.8.13 which is not adaptable and libapache2-mod-php need 7.0.8

Apache 服务器无法启动,因为未安装 libapache2-mod-php7.0:默认情况下 aptitude 或 apt install php7.0-common version 7.8.13 不适应,libapache2-mod-php 需要 7.0.8

  1. remove php-common
  2. download http://packages.ubuntu.com/xenial/php7.0-commondeb package and install it if it compains about php7.0-json, readline,cli,opache then seatch in upper textbox about those library and install them in this manner
  3. json
  4. opach
  5. cli
  6. readline

  7. install libapache2-mod-php7.0 RESTART APACHE 2 service apache2 restart

  1. 删除 php-common
  2. 下载http://packages.ubuntu.com/xenial/php7.0-commondeb 包并安装它,如果它包含关于 php7.0-json、readline、cli、opache 然后在关于这些库的上部文本框中查找并将它们安装在这种方式
  3. json
  4. 奥帕奇
  5. 命令行
  6. 阅读线

  7. 安装 libapache2-mod-php7.0 RESTART APACHE 2 service apache2 restart

it must working probably Good Luck!

它必须工作可能祝你好运!

回答by Max Gabderakhmanov

Try for Ubuntu 16.04:

尝试 Ubuntu 16.04:

sudo apt-get update;
sudo apt-get install php7.0-fpm php7.0-mysql <other packages>;

for Ubuntu 14.04:

对于 Ubuntu 14.04:

sudo apt-get update;
sudo apt-get install php5-mysql php5-mysql <other packages>;

回答by rossiya

It should be:

它应该是:

sudo apt-get install libapache2-mod-php7.0

须藤 apt-get 安装 libapache2-mod-php7.0

回答by Chad_G

sudo apt-get install libapache2-mod-php7.1

worked for me (16.04Ubuntu).

为我工作(16.04Ubuntu)。