E: Package 'apache2' has no installation candidate on Ubuntu 17.10

11,431

Solution 1

The main problem is missed /etc/apt/sources.list. You can recreate it with:

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

Then run

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

Solution 2

Try sudo apt-get update and then sudo apt-get install apache2. I recommend installing the complete LAMP Stack using tasksel

sudo apt-get install tasksel

sudo tasksel to launch it Select LAMP server and install it. Hope that helps.

Share:
11,431

Related videos on Youtube

Kiran Shahi
Author by

Kiran Shahi

Updated on September 18, 2022

Comments

  • Kiran Shahi
    Kiran Shahi over 1 year

    Got error E: Package 'apache2' has no installation candidate while installing apache2 with sudo apt-get install apache2 on Ubuntu 17.10. Here is the message displayed on terminal.

    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
    

    Message after apt-cache policy apache2 command.

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

    Message after egrep -v '^#|^ *$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list command

    /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
    

    How can I solve this issue?

    Screen shot of error while installing apache2

    • N0rbert
      N0rbert about 6 years
      Please edit your question and add output of apt-cache policy apache2 to it.
    • pomsky
      pomsky about 6 years
      Also please add the contents of your /etc/apt/sources.list file.
    • Kiran Shahi
      Kiran Shahi about 6 years
      inside /etc/apt/ there is no sources.list file
    • N0rbert
      N0rbert about 6 years
      Please add output of egrep -v '^#|^ *$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list to the question.
    • Knud Larsen
      Knud Larsen about 6 years
      The install command is sudo apt update && sudo apt install apache2
    • pa4080
      pa4080 about 6 years
    • Kiran Shahi
      Kiran Shahi about 6 years
      @N0rbert I have updated output of the command you have mentioned.
  • Kiran Shahi
    Kiran Shahi about 6 years
    Thank you for your answer. But I need to install LAMP manually.
  • Ilak
    Ilak almost 4 years
    A note for future internet searchers who may come across this answer: if you're using a version other than 17.10, replace "artful" with your version's name (rather than copy/pasting the whole thing directly into your terminal as I did.)
  • N0rbert
    N0rbert almost 4 years
    @Ilak thanks for idea, I edited the answer to make it universal.