2

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

7
6

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
2
  • 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.) – Ilak Jul 20 '20 at 2:30
  • @Ilak thanks for idea, I edited the answer to make it universal. – N0rbert Jul 20 '20 at 5:37
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.

1
  • Thank you for your answer. But I need to install LAMP manually. – Kiran Shahi Mar 23 '18 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.