Problem with restarting Apache 2

I found this: How do I restart/reload Apache when it can't determine the domain name?

Good news! Apache is restarting successfully. Apache just isn't sure where you want serve from, so it's choosing your localhost (127.0.0.1) by default. To prevent this message from appearing, clarify that you want to serve from localhost (127.0.0.1) by adding the following line into your /etc/apache2/apache2.conf file:

ServerName localhost

Specifying ServerName localhost in your configuration files outside of the virtual host sections is the way to do this.

Other answers suggest that you should modify /etc/apache2/httpd.conf. This file gets overwritten when apache gets upgraded from apt. For Apache configuration that you don't want to get overwritten, you should create a new file. Here is the "Debian way" to make this configuration change:

# create the configuration file in the "available" section
echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/servername.conf
# enable it by creating a symlink to it from the "enabled" section
sudo a2enconf servername
# restart the server
sudo service apache2 restart

Your localhost IP Address should be 127.0.0.1, instead of 127.0.1.1. Please setup your /etc/hosts file properly. Then edit the httpd.conf file:

sudo -H gedit /etc/apache2/httpd.conf

When a blank file appears, please add this line, then save:

ServerName localhost

Tags:

Apache2