If your ubuntu has apache2 installed already and you want to remove it parmanently you can follow the steps below to completely remove it:
# stop the running apache first sudo service apache2 stop # remove all apache references sudo apt remove apache2.* # autoremove if something is still dependent on apache sudo apt autoremove # check to see if apache is completely removed # following command should return blank which apache2