A script to restart Apache after power failure in 10.2

Mar 08, '05 10:11:00AM

Contributed by: Anonymous

I've seen a couple of fairly complex hints that were written to overcome the bug in OS X 10.2 that fails to restart the Apache webserver after a power failure. Being a UNIX newbie (fear of complex UNIX hints), and already having some experience with AppleScript's ability to execute shell scripts through the do shell script command, I thought I'd try creating an AppleScript solution. I wanted to create an application to run as a StartUpItem that starts the Apache server via an apachectl start command. It works and is dead simple:

Open Script Editor, and type the following line in, changing the placeholder value yourpassword to your administrator password:

do shell script ¬
 "/usr/sbin/apachectl start" password ¬
 "yourpassword" with administrator privileges
Save 'Start Apache' as file format Application in a convenient location. Set the application to run on startup (in 10.2, this is in the Preference Pane 'Login Items'). Energy Saver option 'Restart automatically after a power failure' must be checked. Toggle the switch on your power source to test (close all open files first, of course!).

Comments (8)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2005030511282285