E:软件包‘apache2’没有安装候选项

E:软件包‘apache2’没有安装候选项

当我尝试在 Ubuntu 14.04 上安装 apache2 时,收到以下错误消息:

root@Final-Gitsetup-Developers:~# apt-get install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package apache2 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
However the following packages replace it:
  libapache2-mpm-itk libapache2-mpm-itk:i386

E: Package 'apache2' has no installation candidate 

结果apt-cache policy | grep http | awk '{print $2 $3}' | sort -u

http://archive.ubuntu.com/ubuntu/trusty/universe  
http://repo.mysql.com/apt/ubuntu/wily/mysql-5.6  
http://repo.mysql.com/apt/ubuntu/wily/mysql-apt-config  
http://repo.mysql.com/apt/ubuntu/wily/mysql-tools  

答案1

/etc/apt/sources.list文件中所有包含字符串(Ubuntu 15.10)的软件源wily都与您的 Ubuntu 14.04 软件源相冲突,导致您无法安装 apache2。要解决此问题,请在包含字符串wilyxenial的每一行前面添加一个#字符,以将其转换为注释。

使用 nano 文本编辑器编辑/etc/apt/sources.list文件。打开终端并输入:

sudo nano /etc/apt/sources.list  

Ubuntu 14.04 的标准 sources.list 文件如下所示:

deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse  
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu trusty-security main restricted universe multiverse  
deb http://archive.canonical.com/ubuntu trusty partner    
deb http://extras.ubuntu.com/ubuntu trusty main   

由于您使用的是 Ubuntu 14.04,因此上述标准 sources.list 文件中的每一行都包含该字符串trusty。将其他 Ubuntu 版本(例如 15.10 或 16.04)的存储库添加到您的 Ubuntu 14.04 软件源中是非常糟糕的包管理。

Nano 编辑器键盘快捷键
使用键盘组合键Ctrl+O然后按 将Enter文件保存到当前位置。
使用键盘组合键Ctrl+X退出 nano。

更新可用软件列表并安装 apache2。

sudo apt update  
sudo apt install apache2  

相关内容