Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I had to install a custom Apache on OSX because I needed a very specific configuration for a client and I could not make the default one work correctly with it, unfortunately.

So, I saw how to start in manually, using apachectl binary:

sudo /usr/local/apache2/bin/apachectl start

And I also saw I can make the default Apache start with a launchctl command.

But, how could I make a custom installed to start at boot, instead of the default one? If it's possible, I would like to use system's launchctl.

share|improve this question
    
Thanks. Added the solution above and marked as the correct answer. –  lucasarruda Jun 3 '13 at 17:52

2 Answers 2

You would do the same as the launchctl procedure you linked to. The missing piece is that you need to make your own launchd.plist and save it in the LaunchDaemons/ directory. man launchd.plist for information on the plist format; or, you can probably copy the original apache one and change the path to suit your needs.

share|improve this answer
1  
Save your own (or copied) plist-file in /Library/LaunchDaemons. And dont forget to either disable the systems httpd-plist or use a different port in your custom httpd.conf otherwise both webservers try to use the same port. And you will have to adapt the apachectl-file when you want to use it to start your own apache. –  heiglandreas May 30 '13 at 9:45
up vote 1 down vote accepted

Solution:

Unloaded default Apache

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

Created a LaunchDaemon file ( /Library/LaunchDaemons/com.aaa.launchd.apache2.plist ):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.aaa.launchd.apache2</string>
<key>ProgramArguments</key>
<array>
    <string>/usr/local/apache2/bin/apachectl</string>
    <string>start</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

Changed file owner:

sudo chown root:wheel /Library/LaunchDaemons/com.aaa.launchd.apache2.plist

And, finally, added it to be loaded on boot

sudo launchctl load -w /Library/LaunchDaemons/com.aaa.launchd.apache2.plist
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.