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

7,600

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
Share:
7,600

Related videos on Youtube

Pranaya Behera
Author by

Pranaya Behera

Updated on September 18, 2022

Comments

  • Pranaya Behera
    Pranaya Behera over 1 year

    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

  • Pranaya Behera
    Pranaya Behera over 10 years
    I have used the sudo service restart apache2 but with that warning. But the virtual hosts are not pointing the correct dir. I have set up the hosts file to point to the servername lemme update my question with the hosts file also.
  • TheCompWiz
    TheCompWiz over 10 years
    AH00558 is simply a message-identifier from apache. Think of it as an "error code". It looks like when the updated package was installed, the "default" site was replaced. You may need to remove the 000-default.conf.dpkg-new and replace the symlink to the original 000-default.conf. (look in sites-enabled rather than sites-available)
  • Pranaya Behera
    Pranaya Behera over 10 years
    Yeah it was not present previously the 000-default.conf.dpkg-new . Do I have to remove this file and then update the contents to the 000-default.conf ?
  • TheCompWiz
    TheCompWiz over 10 years
    No. sites-available are simply confs that could be enabled by using the a2ensite command. Look in the sites-enabled directory for confs that are actually loaded.
  • TheCompWiz
    TheCompWiz over 10 years
    You might also want to check the apache logs or syslog for errors during startup.
  • Pranaya Behera
    Pranaya Behera over 10 years
    sites-enabled dir shows me the all the virtual hosts that i have created and also all those are correctly set.
  • Pranaya Behera
    Pranaya Behera over 10 years
    so by adding Require All Granted will resolve the issue ?
  • Diogenes van Sinope
    Diogenes van Sinope over 10 years
    @PranayaBehera - sorry for the delayed reply -- my dev sys is a win/ubuntu dual boot, drupal multsite configuration behind a firewall, blah, blah, blah. I just want things to work. YMMV.
  • Diogenes van Sinope
    Diogenes van Sinope over 10 years
    @PranayaBehera LOL - tried to edit the above post, but you only have 5 minutes to do this. It's like a speed date. I wanted to add that 'Require All Granted' probably sucks in a security context YMMV.