When I tried to install Apache in Ubuntu 18.04 using the command sudo apt install apache2
, I got:
E: Distorted line 2 in the sources list /etc/apt/sources.list.d /official-package-repositories.list
E: The list of sources is not read.
E: Distorted line 2 in the sources list /etc/apt/sources.list.d/official-package-repositories.list
The second line contains the word universe
. After I deleted it, I got:
The apache2 package is not available, but is listed in the dependency list of another package.
E: No installation candidate found for the “apache2” package.
Comment out line 2 in
//etc/apt/sources.list.d/official-package-repositories.list
by preceding that line with a # character. Open the terminal and type:Comment out line 2.
The instructions for using nano editor are always found at the bottom of every page. Press the keyboard combination Ctrl+O and after that press Enter to save the file being edited. Press the keyboard combination Ctrl+X to exit nano.
Add the main repository to
/etc/apt/sources.list
. Open/etc/apt/sources.list
with nano text editor and add the following lines to it.If you get a duplicate entry in sources.list error about any of the 4 new lines that you added, you can open
/etc/apt/sources.list
again in nano text editor, and comment out the duplicate lines by preceding them with a #.Update the list of available software and try to install apache2 again.