Setting the Global ServerName Directive on Ubuntu Apache

Published: 2024-03-02 | Updated: 2024-07-03

Problem

Apache reports an error AH00558 after setting up a server configuration when issuing the restart, reload, or configtest commands

sudo /etc/init.d/apache2 restart

yields

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

Solution

Open apache’s main config file with your favorite editor (vim, nano, gedit…)

sudo vim /etc/apache2/apache2.conf

And add at end of the file:

# Global ServerName directive
ServerName 127.0.0.1

Save and exit and test config

sudo apachectl configtest
# Syntax OK
sudo /etc/init.d/apache2 restart

The error is no more.