这可能是最快的

这可能是最快的

E: Package 'apache2' has no installation candidate在 Ubuntu 17.10 上安装 apache2 时出错sudo apt-get install apache2。以下是终端上显示的消息。

sudo 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

E: Package 'apache2' has no installation candidate

命令后的消息apt-cache policy apache2

apache2:
  Installed: (none)
  Candidate: (none)
  Version table:

egrep -v '^#|^ *$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list命令后的消息

/etc/apt/sources.list.d/linuxgndu-ubuntu-sqlitebrowser-artful.list:deb http://ppa.launchpad.net/linuxgndu/sqlitebrowser/ubuntu artful main
/etc/apt/sources.list.d/mongodb-org-3.6.list:deb [arch=amd64,arm64] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse
/etc/apt/sources.list.d/slack.list:deb https://packagecloud.io/slacktechnologies/slack/debian/ jessie main
/etc/apt/sources.list.d/sublime-text.list:deb https://download.sublimetext.com/ apt/stable/
/etc/apt/sources.list.d/vscode.list:deb [arch=amd64] http://packages.microsoft.com/repos/vscode stable main
/etc/apt/sources.list.d/webupd8team-ubuntu-java-artful.list:deb http://ppa.launchpad.net/webupd8team/java/ubuntu artful main

我该如何解决这个问题?

安装 apache2 时出错的屏幕截图

答案1

主要问题被遗漏了/etc/apt/sources.list。你可以用以下方法重现它:

cat <<EOF | sudo tee /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs) main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-backports main universe restricted multiverse
EOF

然后运行

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install apache2

答案2

尝试sudo apt-get update一下sudo apt-get install apache2。我建议使用以下方法安装完整的 LAMP Stacktasksel

sudo apt-get install tasksel

sudo tasksel启动它选择 LAMP 服务器并安装它。希望有帮助。

答案3

这可能是最快的

  1. 跑步sudo software-properties-gtk
  2. 在下面 'Ubuntu 软件'标签选择/勾选前 4 个选项-主要的宇宙受限制的多元宇宙
  3. 点击 '关闭
  4. 点击 '重新加载

现在,再次尝试安装命令。

答案4

按照下面的步骤一步一步操作。

1.通过终端打开您的源列表,然后输入“sudo nano /etc/apt/sources.list”

    sudo nano /etc/apt/sources.list

2. 复制并粘贴到您的列表下。请使用此代码在旧代码列表的字体中输入“#”。

    deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi

    deb http://archive.raspbian.org/raspbian/ bullseye main contrib non- free rpi
    
    deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

    deb http://archive.raspberrypi.org/debian/ buster main contrib non-free rpi

    deb http://archive.raspberrypi.org/debian/ buster main

    deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs) main restricted universe multiverse

    deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-updates main restricted universe multiverse

    deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-security main restricted universe multiverse

    deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-backports main universe restricted multiverse

3.ctrl x 然后 y 然后输入“在键盘上”

4.sudo systemctl status apache2 你会得到“找不到单元 apache2.service”。

    sudo systemctl status apache2

5.sudo apt更新&& sudo apt升级-y

    sudo apt update && sudo apt upgrade -y

6.sudo systemctl status apache2

    sudo systemctl status apache2

7.sudo apt 安装 apache2 -y

    sudo apt install apache2 -y

8.主机名-I

    hostname -I

9.转到您的网络浏览器,地址是“ Localhost ”

完毕 。

相关内容