1

I'm trying to restart my Apache but it doesn't work. This is the error:

Restarting web server apache2 
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

I need some help. Thank you

4
  • That's not an error, just a warning about a configuration problem. Are you sure you cannot access the server when you receive that message? Aug 6, 2013 at 13:33
  • If I go on localhost it appears a window: You have chosen to open: witch is a: PHTML file from localhost Aug 6, 2013 at 13:38
  • Sounds like Apache is running (run sudo service apache2 status to confirm), but you're serving out a .phtml file as your index in web root (typically /var/www). This is not normal, so I'd double-check your apache config to see why it is pointing to that file. Aug 6, 2013 at 14:06
  • It is running but my index is .php in var/www Aug 6, 2013 at 14:09

3 Answers 3

2

First of all, I believe the newer versions of Apache do not use httpd.conf or any of that so I'm not going to discuss "httpd" anything.

I believe the right way to make this warning go away is to NOT TOUCH apache2.conf.

I've read that this file is updated any time apache2 is updated and if you're like me, you don't want things you've already done to get undone. So use a .conf file under /etc/apache2/available-sites/

My installation had a default file... like 000-default.conf. If yours doesn't you should probably google a2enconf and learn about creating the .conf files and using a2enconf to make the symlinks.

First thing I did was uncomment ServerName and set it to localhost expecting the warning to go away. Alas, the warning was still there.

My warning had the word 'global'. So I realized the line I changed was inside a <VirtualHost> tag and supposed that wasn't global. I added "ServerName localhost" on the outside of the vhost tag but still in the 000-default.conf file and voila. Problem solved. And I didn't need to touch apache2.conf so I will never have to bugger with this again even when I update and Apache overwrites apache2.conf. I Hope this clarifies some things about the warning. I hate warnings as much as errors. I like everything to function perfectly but also quietly.

2

A hostname is called fully qualified when a domain name is appended to it.

servername is not fully qualified, servername.domainname.org is.
When the command hostname is used to return the hostname of a system, hostname -f is used to return the fully qualified hostname.

If you run this command on your system and it return nothing, then you may expect this warning in Apache and in some other programs too.

In this case, if you really want to cure to problem, you will have to define /etc/hosts accordingly :

<your ip> servername.domainname servername

Example, if my IP is 10.1.1.1, my domain example.com and my hostname host1, a minimal /etc/hosts file would be :

127.0.0.1   localhost.localdomain localhost
10.1.1.1    host1.example.com host1

After this, the command hostname will return host1 and hostname -f returns host1.example.com.

By doing so, no need to tell your Apache that your hostname is localhost. No need to modify the main Apache configuration file, so the next time Apache will be updated, you won't loose your setting or have the new config file not merged into the existing one.

1
  • +1 because this explain the cause of the problem and solve it globaly. servername localhost is just a workaround valid only for Apache. What if the OP install a mail server requiring also some fully qualified hostname ? it will break too, unless you apply this solution.
    – Justin
    Aug 7, 2014 at 13:32
0

To fix that problem, you need to edit the httpd.conf file. Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

sudo gedit /etc/apache2/httpd.conf

By default httpd.conf file is blank, just add the following:

ServerName localhost

Once you're done, save the file, and restart the server.

sudo /etc/init.d/apache2 restart

OR

To solve this problem just set ServerName.

sudo nano /etc/apache2/conf.d/name

For example set the name as localhost or any other name that you want:

ServerName localhost

The just restart Apache 2

sudo /etc/init.d/apache2 restart
2
  • This is just a workaround, not a real solution.
    – Justin
    Aug 7, 2014 at 13:32
  • @Justin see addition in my answer.
    – Mitch
    Aug 7, 2014 at 14:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .