Issue
I'm a newbie in linux and having problem with installing apache2. I've installed and uninstalled apache2 once. Used href="http://xmodulo.com/how-to-uninstall-and-remove-apache2-on-ubuntu-debian.html" rel="nofollow noreferrer">this article to uninstall apache2. After that, it's not getting installed/working. So far these are the things I've tried as root user.
> sudo apt-get install apache2
....... apache2 is already the newest version (2.4.18-2ubuntu3). .......
I can't find any directory named apache2 though using the following command.
> whereis apache2
I'm not getting any response in the browser with http://localhost/
since apache2 was not installed properly.
Solution
apache2 is a metapackage that just selects other packages. If you installed apache by installing that package, you just need to run this to clean up the automatically selected packages:
sudo apt-get autoremove
if that doesn't work, you might have installed one of the dependents manually. You can target all the apache2- packages from space and nuke the lot:
sudo apt-get remove apache2
You can do the following two tests to confirm apache has been removed:
- which apache2 - should return a blank line
- sudo service apache2 start - should return apache2: unrecognized service
Then to install apache2 you need to excute commands in this order :-
**
- sudo apt-get update
- sudo apt-get install apache2
** 3. Press Y and hit Enter to continue, and the installation will proceed. Next you need to set your ServerName globally in /etc/apache2/apache2.conf as following :- **
sudo nano /etc/apache2/apache2.conf
** Add this line to the bottom of apahce2.conf file ( if you dont know your server domain you can use your server ip address) then Save and close the file when finished:- **
ServerName server_domain_or_IP
** Next, check for syntax errors by typing: **
sudo apache2ctl configtest
** if everything is ok you need to restart apache service to make changes effective as folowing:- **
sudo systemctl restart apache2
**
Answered By - Blacky Bird Answer Checked By - Marie Seifert (WPSolving Admin)