Localhost Apache 2 Server Warning On Ubuntu 11

I was recently setting up a localhost environment with Ubuntu 11 and after adding all of my needed VirtualVost directives I found that I could start/restart the server but that I found the following error when trying to start the server.

user2@machine:/etc/apache2/sites-available$ sudo apache2ctl -k start
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

To fix the problem you needed to add a simple directive to the Apache httpd.conf file. In order to access this file you'll need be have admin access, so open up a terminal window and type the following command.

sudo gedit /etc/apache2/httpd.conf

Don't worry if the file you open is empty, it is meant to be. The httpd.conf file is a user editable file that you can add directives to in order to configure your Apache install. What we need to do with this file is enter a directive that will give the server a name. Because we are not using a DNS server (as it is local) we need to let Apache know what to call itself. Enter the following directive.

ServerName localhost

Save this file and close it. When you are done you can restart the server by typing in the following command.

sudo apache2ctl -k restart

Your Apache server will now start with no annoying warnings or errors (as long as the rest of your configuration is correct).

Comments

apache is awesome, but  nginx is way more efficient.

Permalink

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
2 + 15 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.