I recently upgraded my Macbook to OS X El Capitan (10.11). As expected, Apache did not immediately work upon upgrade. In this case, it was because upgrading from Yosemite to El Capitan also upgraded Apache from 2.2 to 2.4.
Unfortunately, unlike in times past, this time Apache did not give me any feedback as to why it was not working. When I ran
curl localhost from the command line I simply got:
curl: (7) Failed to connect to localhost port 80: Connection refused
While my web browser gave a standard “This site can’t be reached” error.
Not helpful. I found nothing in the Apache error log (/var/log/apache2/error_log) either.
I tried restarting apache (
sudo apachectl restart). Still nothing.
However, this little command helped me tremendously:
This revealed a syntax error in my apache configs. In my case, I was attempting to use the SSL module (specifically, calling SSLEngine in my passenger config) without actually loading it. If you aren’t seeing anything in the apache logs, despite the fact that running
sudo apachectl start returns a message saying apache is already running, then you may also have a syntax error somewhere in your configs. Try out apachectl configtest and see what you find.
In my situation, uncommenting “LoadModule ssl_module libexec/apache2/mod_ssl.so” in httpd.conf did the trick and I got apache up and running.
Hopefully this will help a fellow developer whose sysadmin skills, like mine, could use some work.