When setting up Apache on a server we may have the warning "Could not reliably determine the server’s fully qualified domain name." This warning typically appears when Apache is started or restarted. It doesn't necessarily indicate a critical issue but it's important to understand and resolve it to ensure proper server configuration.
Problem Statement
Upon starting or restarting Apache, we get the following warning message:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name using the 127.0.1.1. Set the 'ServerName' directive globally to suppress this message. This warning indicates that Apache cannot determine the fully qualified domain name (FQDN) of the server.
Set ServerName in httpd.conf or apache2.conf
Edit the Apache configuration file. Add or update the ServerName directive to specify the server's FQDN. This can be set globally to suppress the warning message.
Example:
ServerName example.com- Replace example.com with the actual domain name.
Code:
sudo nano /etc/apache2/apache2.conf# Set ServerName directive globallyServerName example.comOutput:
- After saving the changes, restart Apache to the apply the configuration:
sudo systemctl restart apache2- Verify the Apache configuration for the any syntax errors:
sudo apache2ctl configtest- If no errors are reported, the warning should be resolved the upon restarting Apache.
Use IP Address in ServerName
- Alternatively, if we prefer, we can use the server's IP address instead of the domain name.
ServerName 192.168.1.1- Replace 192.168.1.1 with the server's actual IP address.
Code:
sudo nano /etc/apache2/apache2.conf
# Set ServerName directive with IP address
ServerName 192.168.1.1
Output:
- Save the changes and restart Apache:
sudo systemctl restart apache2- Verify the configuration:
sudo apache2ctl configtestConclusion
By setting the ServerName directive in Apache's configuration file we can resolve the warning about not being able to the determine the server's fully qualified domain name. This ensures proper server configuration and eliminates unnecessary warning messages during the Apache startup or restart.