Ubuntu – Recent Apache2 update broke virtual host and New Error on restart or starting

apache-http-serverUbuntuubuntu 12.04virtual-host

I am on Ubuntu 12.04 box, recently installed one apache2 update, and since then all the virtual hosts are not pointing to the correct directories, it's now pointing to the default localhost. Also I am getting an error on apache2 restart:

shafox@shafox:~$ sudo /etc/init.d/apache2 restart
* 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 [ OK ]. 

I know I haven't set up the servername is not localhost, but why there is a AH00558 stamp before the error message?
This is my sites-available in my system:

/etc/apache2/sites-available$ ls
000-default.conf       default-ssl.conf  localbox-local
000-default.conf.dpkg-new  devbox-dev        sites-si

Previously it was like this:

/etc/apache2/sites-available$ ls
000-default  default-ssl  localbox-local  devbox-dev   sites-si

For example one of the virtual host file looks like this:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName localbox.local
        DocumentRoot /home/shafox/Localbox
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /home/shafox/Localbox/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

I don't want to create all these virtual hosts again. I have followed the steps written in this tutorial to create all these virtual hosts.

Here is my /etc/hosts file:

127.0.0.1       localhost
127.0.1.1       shafox
127.0.1.1       devbox.dev
127.0.1.1       localbox.local
127.0.1.1       sites.si

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Error logs from the apache2 error.log
Error Log Link

Best Answer

That is not technically an "error"... but it is a warning. Previous init.d scripts would simply put that warning into the logs, and report nothing when restarting. The message is accurate in that Apache has no way to identify the server's fqdn based on the information available. You could simply add to the loopback interface entry in the hosts file like this:

127.0.1.1       servername server.fully.qualified.name.tld

or specify the ServerName directive as the warning suggests in the apache.conf:

ServerName www.example.com

Also, if you've decided to use ubuntu, you really should use the upstart commands to control services like apache instead of the init.d scripts. Like this:

sudo restart apache2
Related Question