Start – Stop Apache HTTP server by click

Usually, you start and stop the apache server by the terminal on Mac OS X.

Example

# start Apache
$ sudo apachectl start

# Restart Apache
$ sudo apachectl restart

# Stop Apache
$ sudo apachectl stop

But with the help of Automator, you can do it by simple click.

Steps

Start the Automator and select “Application”.

automator apache

Now insert the action “Run AppleScript” from library into workflow window.

automator apple script

Insert the following script and save your application.

do shell script "
!#/usr/bin/env bash
if ! ps ax | grep httpd | grep -v grep > /dev/null ; then
  sudo apachectl start
else
  sudo apachectl stop
fi
" with administrator privileges

As a small highlight you can change the icon. Select your app and press “CMD” + “i”. Now drag an other icon file on place of Automator icon.

automator icon