How to automatically start Apache on macOS boot

Apache is installed by default on macOS, but it’s not configured to start during system boot automatically. For this, you’ll have to manually start the httpd process every time you want to use it.

user@host $ sudo apachectl -k start
AH00112: Warning: DocumentRoot [/usr/docs/] does not exist
AH00112: Warning: DocumentRoot [/usr/docs/] does not exist

It’s a good default setting as most macOS users will not need a web server running all the time in the background. Still, if you’re a web developer, for example, you might want Apache to start automatically whenever macOS boots up.

Steps to automatically start Apache during macOS startup:

1. Launch Terminal application.

2. Use launchctl to automatically load Apache‘s startup script during system boot.

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

3. Start httpd process manually to use Apache immediately.

sudo apachectl -k start

4. Check if httpd process successfully run.

ps -aef | grep httpd

5. Disable Apache from automatically starting up during system boot when no longer necessary.

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


Leave a Comment