Once after installing and configuring Apache2 on Ubuntu Server 20.04, I noticed the following error in the /var/log/apache2/error.log logs:
AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1. Set the ‘ServerName’ directive globally to suppress this message
At the same time, the ServerName directive was specified for sites configured in /etc/apache2/sites-enabled/, but not globally specified as written in the error.
Therefore, to resolve the error, I opened the main Apache2 configuration file:
nano /etc/apache2/apache2.conf
And after # Global configuration, pointed out:
ServerName localhost
Then I checked the correctness of the configuration:
apache2ctl -t
Syntax OK
And applied the config:
service apache2 reload
Alternatively, you can restart apache2:
service apache2 restart
After that, the error was resolved.
See my other articles on Apache2