How to run httpd on macOS without Apache I'm trying to build a BCHS application. I do have a remote server running OpenBSD, but the network latency is killing me, so I decided to develop on my MacBook Air and deploy to the OpenBSD server later.

I haven't installed Apache yet (and don't think I'll need it), but httpd seems to be a built-in utility of macOS.

~
❯ httpd -v
Server version: Apache/2.4.28 (Unix)
Server built:   Oct  9 2017 19:54:20


I tried to start httpd with the following methods, but they didn't work:

❯ launchctl enable httpd
Unrecognized target specifier. &lt;service-target&gt; takes a form of &lt;domain-target&gt;/&lt;service-id&gt;.
Please refer to `man launchctl` for explanation of the &lt;domain-target&gt; specifiers.
Usage: launchctl enable &lt;service-target&gt;

~
❯ launchctl start httpd

~
❯ launchctl list | grep httpd

~
❯ httpd
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs


TL;DR

I want to launch httpd as a daemon. How do I do that?
There is a LaunchDaemon service for Apache in /System/Library/LaunchDaemons, org.apache.httpd.plist. You can load it using:

sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

Obviously you'll need to configure httpd.conf appropriately first.

The -w should set the .plist's Disabled key to false so it will start on boot.

NOTE: load is classified as a legacy sub-command of launchctl but still works in High Sierra. I attempted to start Apache with sudo launchctl enable system/org.apache.httpd but it didn't seem to do anything, possibly because I have no idea how to use enable. :P

DOUBLE NOTE: Apache needs elevated privileges, hence nothing happening when you just ran httpd. sudo httpd will work but again configure it first.