3

I recently installed PHP-7.1 through homebrew on MacOS Sierra, and everything stopped working. Odd errors, permission issues, and so on. Now I'm trying to stop Apache (that ships with Sierra) and Apache just won't die.

Kill it:

$ sudo apachectl stop
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
httpd (no pid file) not running

Check if it's running:

$ sudo lsof -i:80
COMMAND   PID USER   FD   TYPE            DEVICE SIZE/OFF NODE NAME
httpd    3722 _www    4u  IPv6 0x123456789abcdef      0t0  TCP *:http (LISTEN)
httpd    3724 _www    4u  IPv6 0x123456789abcdef      0t0  TCP *:http (LISTEN)
httpd    3725 _www    4u  IPv6 0x123456789abcdef      0t0  TCP *:http (LISTEN)
httpd   56048 root    4u  IPv6 0x123456789abcdef      0t0  TCP *:http (LISTEN)
httpd   56055 _www    4u  IPv6 0x123456789abcdef      0t0  TCP *:http (LISTEN)

Hit Apache with a status check:

$ apachectl status
Go to http://localhost:80/server-status in the web browser of your choice.
Note that mod_status must be enabled for this to work.

Let's try that link:

$ curl http://localhost:80/server-status
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /server-status
on this server.<br />
</p>
</body></html>

Okay then let's try to fix httpd.conf and restart Apache:

$ sudo nano /etc/apache2/httpd.conf
$ sudo apachectl restart
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

Oh, and just to confirm in /etc/apache2/httpd.conf I have both of these lines uncommented:

ServerName localhost

LoadModule status_module libexec/apache2/mod_status.so

What's wrong with Apache, and how do I stop it all so I can start over?

1
  • Glancing at the problem and the commands.. And still my first inclination was to ask you to make sure that your Apache is also updated. I've done this more than once. Update PHP, woohoo! Broken. Update Apache okay fixed. Make sure you go to the Apache site and click all the updated links and update all of it. Sometimes the new PHP doesn't work if something else didn't get the updates. Including the C++ link that it requires too. – ejbytes Apr 9 '17 at 3:10
2

If you successfully stop Apache with the command sudo apachectl stop, you will still see the output you saw when you issued the apachectl status command. E.g., I can see that Apache is listening on port 80 on my OS X El Capitan system with the netstat command, stop it, check the status, which shows the same message you posted, but verify that Apache is no longer listening on port 80.

$ netstat -an | grep '.80' | grep -i Listen
tcp46      0      0  *.80                   *.*                    LISTEN
$ sudo apachectl stop
Password:
$ apachectl status
Go to http://localhost:80/server-status in the web browser of your choice.
Note that mod_status must be enabled for this to work.
$ netstat -an | grep '.80' | grep -i Listen
$

So seeing that output from apachectl status doesn't mean Apache is still running. You can verify that it is no longer listening on port 80 using the command netstat -an | grep '.80' | grep -i Listen or check on whether the Apache process httpd is running as shown below.

$ ps aux | grep httpd | grep -v grep
_www            45379   0.0  0.0  2509492   1084   ??  S     6:27PM   0:00.00 /usr/sbin/httpd -D FOREGROUND
root            45376   0.0  0.1  2511540  11292   ??  Ss    6:27PM   0:00.19 /usr/sbin/httpd -D FOREGROUND
$ sudo apachectl stop
Password:
$ ps aux | grep httpd | grep -v grep
$

The "403 Forbidden" error message may be due to a file permissions problem. If you place some html file in the DocumentRoot directory with read access granted to all, e.g., chmod 644 index.html and try accessing it, what do you see? You may also find a clue to the problem you are experiencing by examining the Apache error log file. You can see the location for the file using the apachectl -S command. E.g.:

$ apachectl -S
AH00557: httpd: apr_sockaddr_info_get() failed for GSSLA15122293
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
VirtualHost configuration:
*:80                   myserver.example.com (/private/etc/apache2/extra/httpd-vhosts.conf:24)
ServerRoot: "/usr"
Main DocumentRoot: "/Library/WebServer/Documents"
Main ErrorLog: "/private/var/log/apache2/error_log"
Mutex proxy: using_defaults
Mutex default: dir="/private/var/run/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex proxy-balancer-shm: using_defaults
PidFile: "/private/var/run/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="_www" id=70 not_used
Group: name="_www" id=70 not_used

The output above is what I see on my system. Even though Apache is complaining that it "Could not reliably determine the server's fully qualified domain name", I can access the index.html file I placed in my DocumentRoot directory via http://localhost, though I set ServerName and DocumentRoot in a VirtualHost section in /private/etc/apache2/extra/httpd-vhosts.conf. The "Could not reliably determine the server's fully qualified domain name" doesn't mean Apache isn't listening for connections. It is if you get the "403 Forbidden" error when attempting to access a page on the server, because that is an error message returned by the web server.

2

Since you've installed PHP via Homebrew, I believe you've multiple installation of Apache, so make sure you're running the right one.

First of all, check different versions of apachectl by running: which -a apachectl.

Then to check which Apache config file is associated with which apachectl, run:

apachectl -t -D DUMP_INCLUDES

If you're planning to start Apache shipped with Sierra, prefix with the right path, e.g.:

/usr/sbin/apachectl -t -D DUMP_INCLUDES
/usr/sbin/apachectl start

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.