5

I updated MacOS Sierra's Apache and PHP, and now whenever I $ sudo apachectl restart I get this:

AH00557: httpd: apr_sockaddr_info_get() failed for My-MacBook-Pro.local
AH00558: httpd: 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

Things I've tried so far that didn't work:

  • Setting ServerName localhost in /etc/httpd.conf
  • Setting ServerName localhost:80 in /etc/httpd.conf
  • Setting ServerName 127.0.0.1 in /etc/httpd.conf
  • Setting ServerName 127.0.0.1:80 in /etc/httpd.conf
  • Ensuring 127.0.0.1 localhost is set in /etc/hosts
  • Repeatedly restarting Apache
  • How did you update Apache and PHP and why because usually it's not recommended to modify the system's Apache & PHP – klanomath May 17 '17 at 14:35
3

The error message you provided gives you the answer:

Set the 'ServerName' directive globally to suppress this message

So, in your httpd.conf file, you need to set the server name by un-commenting and editing the following line

#ServerName www.example.com:80

to...

ServerName www.some-web-server.com

This should be done in the main httpd.conf and should be the FDQN (fully qualified domain name) of the server you are running. Keep in mind that this is for the main server. You can set individual server names in the VirtualHost definitions

For instance, if you called the server - mywebser.local, that should be the ServerName.

Personally, what I like to do, even in a home setup is to have a main definition that goes nowhere and is very restrictive and create virtual hosts in separate directories so each one can be referenced by a different hostname.

3

When restart the httpd.

Try:

sudo /usr/sbin/apachectl restart

Don't use:

sudo apachectl restart
  • 2
    It worked, would you explain more why do I use sudo /usr/sbin/apachectl restart ? – Mike Nguyen May 24 '17 at 4:48
  • It's because you have two different installations of Apache - the one that came with the system and the one you installed yourself. – Allan May 26 '17 at 14:06
2

As per message:

Set the 'ServerName' directive globally to suppress this message.

you need to find your httpd.conf Apache configuration file for example by this command:

apachectl -t -D DUMP_INCLUDES

For example: /usr/local/etc/httpd/httpd.conf.

then edit it and uncomment the line with ServerName (make sure it has the valid server name). E.g.

ServerName localhost
  • If you read the question, you'll find this is one of the first things I tried, and it didn't work – TheEnvironmentalist Nov 1 '17 at 15:34
  • 2
    It's because you were editing the wrong httpd.conf, not in /etc, but the one suggested by apachectl, which on macOS is usually somewhere in /usr/local/etc/httpd/. – kenorb Nov 1 '17 at 15:49
0
  1. When restart the httpd, you should check which apachectl.

  2. Trying restart system apache server by sudo /usr/sbin/apachectl restart.

  3. If you install httpd24 via brew, you should edit your custom apache config.

    Try open $(brew --prefix)/etc/apache2/2.4/httpd.conf, edit the #ServerName www.example.com:80 to ServerName www.your-server.com:80.

    Then sudo apachectl restart will work.

0

I had the same problem on macOS High Sierra and the solutions here worked for me.

I edited the config file:

/usr/local/etc/httpd/httpd.conf

I uncommented and modified the line starting by #Servername with

Servername localhost:8080

This resolved the issue for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .