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:
sudo nano /etc/apt/sources.list.d/official-package-repositories.list
Comment out line 2.
The instructions for using the 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 with nano text editor and add the following lines to it.
deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
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.
sudo apt update
sudo apt install apache2