Running Apache locally keeps development sites, reverse proxies, and test endpoints available immediately after a reboot, instead of requiring a manual server start whenever macOS restarts.

The Apple-bundled Apache httpd is controlled by apachectl, which starts /usr/sbin/httpd using configuration under /etc/apache2 and (by default) serves content from /Library/WebServer/Documents. Boot-time startup is managed by launchd, which loads daemon definitions from LaunchDaemons property lists (.plist) such as /System/Library/LaunchDaemons/org.apache.httpd.plist under the label org.apache.httpd.

Administrator privileges are required because httpd runs as a system daemon and typically binds privileged ports. A broken configuration (for example in /etc/apache2/httpd.conf or an included vhost file) prevents startup and can generate repeated start attempts and log noise. These steps target the Apple-provided Apache; a Homebrew-installed httpd uses a different binary path and a different service-management workflow.

Steps to configure automatic Apache startup on macOS:

  1. Open Terminal.
  2. Validate the active Apache configuration before enabling automatic startup.
    $ sudo apachectl configtest
    Syntax OK

    A syntax error can prevent boot-time startup and trigger repeated restart attempts.

  3. Start Apache once to confirm the current configuration can run.
    $ sudo apachectl start
  4. Confirm the local server responds on localhost.
    $ curl -I http://localhost/
    HTTP/1.1 200 OK
    Date: Sat, 13 Dec 2025 12:34:56 GMT
    Server: Apache/2.4.57 (Unix)
    Content-Type: text/html; charset=UTF-8
    ##### snipped #####

    A port conflict typically shows up as a start failure and a missing response from http://localhost/.

  5. Bootstrap the built-in launchd job definition for Apache.
    $ sudo launchctl bootstrap system /System/Library/LaunchDaemons/org.apache.httpd.plist

    No output is a common success case.

  6. Enable the Apache job so it starts automatically at boot.
    $ sudo launchctl enable system/org.apache.httpd
  7. Start the Apache job immediately under launchd supervision.
    $ sudo launchctl kickstart -k system/org.apache.httpd

    The kickstart -k option terminates any existing instance before starting a fresh one.

  8. Verify launchd reports the job as running.
    $ sudo launchctl print system/org.apache.httpd
    org.apache.httpd = {
        state = running
        pid = 161
    ##### snipped #####
    }
  9. Confirm the job is enabled for boot-time startup.
    $ sudo launchctl print-disabled system
    {
        "org.apache.httpd" => false
    ##### snipped #####
    }

    false indicates the job is not disabled in the system domain.

  10. Disable automatic startup if it is no longer required.
    $ sudo launchctl disable system/org.apache.httpd
  11. Unload the system Apache job from launchd to stop it immediately.
    $ sudo launchctl bootout system /System/Library/LaunchDaemons/org.apache.httpd.plist

    Unloading stops httpd and makes local sites unavailable until Apache is started again.

Discuss the article:

Comment anonymously. Login not required.