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
Password:
AH00112: Warning: DocumentRoot [/usr/docs/dummy-host.example.com] does not exist
AH00112: Warning: DocumentRoot [/usr/docs/dummy-host2.example.com] 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 automatically start whenever macOS boots up.

Steps to automatically start Apache during macOS startup:

  1. Launch Terminal application.
  2. Check if current Apache configuration is valid.
  3. Use launchctl to automatically load Apache's startup script during system boot.
    $ sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
    Password:
  4. Start httpd process manually to use Apache immediately.
    $ sudo apachectl -k start
  5. Check if httpd process successfully run.
    ps -aef | grep httpd
        0   161     1   0 Sun04AM ??         0:04.05 /usr/sbin/httpd -D FOREGROUND
      501   800   161   0 Sun04AM ??         0:02.54 /usr/sbin/httpd -D FOREGROUND
      501  1007   161   0 Sun04AM ??         0:02.62 /usr/sbin/httpd -D FOREGROUND
      501  1381   161   0 Sun07AM ??         0:01.71 /usr/sbin/httpd -D FOREGROUND
      501  4472   161   0 Tue07AM ??         0:01.74 /usr/sbin/httpd -D FOREGROUND
      501  4473   161   0 Tue07AM ??         0:01.17 /usr/sbin/httpd -D FOREGROUND
      501  4474   161   0 Tue07AM ??         0:01.06 /usr/sbin/httpd -D FOREGROUND
  6. Disable Apache from automatically starting up during system boot when no longer necessary.
    $ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 
Discuss the article:

Comment anonymously. Login not required.

Share!