Httpd: Could Not Reliably Determine the Server's Fully Qualified Domain Name, Using 127.0.0.1 for Servername

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Your hosts file does not include a valid FQDN, nor is localhost an FQDN. An FQDN must include a hostname part, as well as a domain name part. For example, the following is a valid FQDN:

host.server4-245.com

Choose an FQDN and include it both in your /etc/hosts file on both the IPv4 and IPv6 addresses you are using (in your case, localhost or 127.0.0.1), and change your ServerName in your httpd configuration to match.

/etc/hosts:

127.0.0.1    localhost.localdomain localhost host.server4-245.com
::1 localhost.localdomain localhost host.server4-245.com

httpd.conf:

ServerName host.server4-245.com

Could not reliably determine the server's fully qualified domain name

Yes, you should set ServerName:

http://wiki.apache.org/httpd/CouldNotDetermineServerName

http://httpd.apache.org/docs/current/mod/core.html#servername

You can find information on the layouts used by the various httpd distributions here:

http://wiki.apache.org/httpd/DistrosDefaultLayout

In your case the file to edit is /etc/httpd/conf/httpd.conf

httpd: Could not reliably determine the server's fully qualified domain name

Ignore ALL of the advice about setting ServerNames. IMHO this is a red herring. Apache is trying to use standard system components to determine a FQDN and not finding anything suitable. Sure, you could subvert this process by adding a directive globally to Apache, but methinks this is treating the symptom. You should have ServerName directives in your virtualhost blocks, of course.

Instead, edit your hosts file and be sure that you have a FQDN listed there. I have seen various suggestions on the syntax for the particular 127* line, but I think that it doesn't matter what order things are in, so long as there is a FQDN listed:

127.0.0.1       localhost.localdomain   localhost       foo.example.com

This worked for me and seemed much more to the point than all of the other "worked for me!" upvotes on posts recommending you edit httpd.conf and such. I hope this helps and that I don't get downvoted. If you disagree, please state why with examples. Thanks.

http://wiki.apache.org/httpd/CouldNotDetermineServerName

Once Apache can determine the system's FQDN, it will then read your specific ServerName directives for your NameBasedHosts.

error AH00558: httpd: Could not reliably determine the server's fully qualified domain name

I found the problem in the comment section of the top rated answer here
I had 2 installations of apache, the one that came with the system and the one I installed using brew install httpd
Error disappeared when I run brew uninstall httpd

Could not reliably determine the server's fully qualified domain name ... How to solve it in Docker?

I'd like to offer another (maybe more Docker-ish) way of solving the warning message. But first, it makes sense to understand what Apache is actually doing to figure out the domain name before just blindly setting ServerName. There is a good article at http://ratfactor.com/apache-fqdn.html which explains the process.

Once we can confirm that getnameinfo is what Apache uses to lookup the name and that it uses /etc/nsswitch.conf to determine where to go first for the lookup, we can figure out what to modify.

If we check out the nsswitch.conf inside the container we can see that it looks up hosts in the /etc/hosts file before external DNS:

# cat /etc/nsswitch.conf | grep hosts
hosts: files dns

Knowing this, maybe we can influence the file at Docker runtime instead of adding it to our configuration files?

If we take a look at the Docker run reference documentation there is a section on the /etc/hosts file at https://docs.docker.com/engine/reference/run/#managing-etchosts. It mentions:

Your container will have lines in /etc/hosts which define the hostname of the container itself as well as localhost and a few other common things.

So, if we just set the container hostname, it will get added to /etc/hosts which will solve the Apache warning. Fortunately, this is very easy to do with the --hostname or -h option. If we set this to a fully qualified domain name, Docker will set it in our /etc/hosts file and Apache will pick it up.

It is pretty easy to try this out. Example with the warning (no hostname):

$ docker run --rm php:7.0-apache
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
[Sun Sep 17 19:00:32.919074 2017] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) PHP/7.0.23 configured -- resuming normal operations
[Sun Sep 17 19:00:32.919122 2017] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

Now with the -h option set to a fully qualified domain name:

$ docker run --rm -h myapp.mydomain.com php:7.0-apache
[Sun Sep 17 19:01:27.968915 2017] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) PHP/7.0.23 configured -- resuming normal operations
[Sun Sep 17 19:01:27.968968 2017] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

Hope this helps answer the question and provide some learning about Apache and fully qualified domain names.



Related Topics



Leave a reply



Submit