Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto start Apache web server during system startup in Mac OS X

Status
Not open for further replies.

Faheemi

Programmer
Sep 2, 2001
59
HK
Hi there,

I wonder how to start Apache web server in the Mac OS X during the system startup. Currently I have to manually start it using the following command

sudo apachectl graceful

How can I automate this during the system startup

Thanks
Hameed
 
You need to create an init script.

Not sure how OSX's structure differs from FreeBSD (probably not much) so try this..

Place the file below in your /usr/local/etc/rc.d

Code:
#!/bin/sh

PREFIX=/usr/local/apache

case "$1" in
start)
        [ -x $PREFIX/bin/apachectl ] &&
        $PREFIX/bin/apachectl start > /dev/null &&
        echo -n ' Apache Started' &&
        echo
        ;;
stop)
        [ -r $PREFIX/logs/httpd.pid ] &&
        $PREFIX/bin/apachectl stop > /dev/null &&
        echo -n ' Apache Stopped' &&
        echo
        ;;
restart)
        $0 stop
        $0 start
        ;;
*)

echo "Usage: `basename $0` {start|stop|restart}" >&2
;;

esac

exit 0

You might want to edit the PREFIX to point to your apachectl file.


/usr/local/etc/rc.d/

M. Brooks
X Concepts LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top