0

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. <service-target> takes a form of <domain-target>/<service-id>.
Please refer to `man launchctl` for explanation of the <domain-target> specifiers.
Usage: launchctl enable <service-target>

~
❯ 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?

closed as unclear what you're asking by klanomath, Allan, fsb, Mark, IconDaemon Feb 15 '18 at 19:16

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • My "answer" is not an "apple centric" answer, so I am putting this in as a comment. What I have found most useful is to light up a VM (VirtualBox is more than sufficient) configure it with bridged networking so it gets an IP on your network, and install BSD and Apache as you normally would. It will work just like your remote server with the added benefit that "clean up" is just removing the VM, not uninstalling servers you no longer need. – Allan Feb 15 '18 at 11:18
  • Flagged unclear! The question doesn't make much sense in the light of httpd -v Server version: Apache/2.4.28 (Unix). The common command to start httpd is sudo apachectl start for httpd bound to ports <1024. – klanomath Feb 15 '18 at 11:42
  • @klanomath I'm confused as to what you're confused about. Shouldn't your answer just be "Run sudo apachectl start"? – JMY1000 Feb 15 '18 at 19:07
2

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.

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