Mac OS X: Restart / Stop / Start Apache2

On Mac OS X, you can use the following commands to restart, stop, and start Apache2:

  1. Restart Apache2:
    sudo apachectl restart
  2. Stop Apache2:
    sudo apachectl stop
  3. Start Apache2:
    sudo apachectl start

These commands require administrative privileges, so you’ll need to enter your password when prompted. Additionally, if Apache2 is not installed on your system, these commands may not work.

Note that on newer versions of macOS (such as macOS Catalina and later), Apache2 is no longer included by default, and has been replaced by the built-in Apache web server, which is managed by the httpd command. To restart, stop, or start the built-in Apache web server, you can use the following commands:

  1. Restart Apache:
    sudo apachectl graceful
  2. Stop Apache:
    sudo apachectl stop
  3. Start Apache:
    sudo apachectl start

Again, these commands require administrative privileges.

Leave a Comment