Off course you’ll want to have Apache started automatically, we will use the new launchd system in Leopard to accomplish this.
Create a file called ‘com.diymacserver.apache2.plist‘ in the directory ‘/System/Library/LaunchDaemons/‘. The content of the file should look like:
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.diymacserver.apache2</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/apache2/bin/apachectl</string>
<string>start</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
To load and activate the .plist file and to make sure that it is started after a reboot you’ll need to load the plist file by using the command:
You can see if it loaded correctly by using the command:
This will show you all the active plist files.
You can see if everything went correctly by trying to start it using:
Next step: Installing PHP



1:06 am
When I tried to load the plist I received the following,
launchctl: opendir() failed to open the directory
nothing found to load
Any ideas?
5:13 am
I guess the error message speaks for it self, did you make an error in the path, did you use sudo, etc… It can’t open the file therefore something is wrong in your commandline.
2:19 am
I admit I’m not very versed in the Mac launchctl process. (I’m not sure I like it.)
Following these startup steps I can use launchctl to ‘load’ the plist — which starts the server. Using the ’start’ subcommand issues no errors. But I observe that the ’stop’ subcommand does not stop the server.
Is this because of the ’start’ command here in the plist? Is it required to ‘unload’ the plist to shutdown the server?
7:56 am
You are correct, the launchctl program is configured to keep the Apache server running. If you like to have more control you could use the ‘old’ method as described here: http://diymacserver.com/installing-apache/starting-apache-at-boot/
It will still work on Leopard but it will be fased out at some point in the future as indicated by Apple.