Mac – AH00558: httpd: Could not reliably determine the server’s fully qualified

apache-http-servermacbook

I am using a Mac book pro. I am trying to find out why my localhost is not working. it keep returning this message;

i ran a apachei configation test :

apachectl configtest

H00557: httpd: apr_sockaddr_info_get() failed for 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

I suspect that this error occurred because i used brew to install several versions of php.

i understand that i need to edit my apache config file with this.

i ran following command to find out which apache file is being used:

apachectl -t -D DUMP_INCLUDES

but this returns the following:

Included configuration files:
  (*) /private/etc/apache2/httpd.conf
    (499) /private/etc/apache2/extra/httpd-mpm.conf
    (505) /private/etc/apache2/extra/httpd-autoindex.conf
    (545) /private/etc/apache2/other/php7.conf
AH00557: httpd: apr_sockaddr_info_get() failed for endys-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

i also use

which -a apachectl

this returned:

/usr/sbin/apachectl

i tried this:

sudo vi /usr/local/apache2/conf/httpd.conf

then added:

 ServerName localhost

but this returned this message:

"/usr/local/apache2/conf/httpd.conf"
"/usr/local/apache2/conf/httpd.conf" E212: Can't open file for writing
Press ENTER or type command to continue

I am now unclear which config file i should change and how i can go about locating it.

EDIT

i also checked my config file to see if its listening to port 80 . this is the settings in the file:

#Listen 12.34.56.78:80
<IfDefine SERVER_APP_HAS_DEFAULT_PORTS>
    Listen 8080
</IfDefine>
<IfDefine !SERVER_APP_HAS_DEFAULT_PORTS>
    Listen 80
</IfDefine>

Best Answer

I am now unclear which config file I should change and how I can go about locating it.

Your apachectl -t -D DUMP_INCLUDES command seems to clearly list /private/etc/apache2/httpd.conf as the primary configuration file for Apache in this instance. Try adding e.g. ServerName localhost to that file.

Related Question