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 can't get XAMPP to start when OS X boots. I've been researching this for some time but with no luck. XAMPP needs to be started as root, and I don't want to store the password for root in a script somewhere and use the "login items" of the accounts pref pane to start xampp. Yes, that will work, but it's not the right way.

I'm trying to launch it using launchd / users damons / LaunchDaemons. That includes creating a plist file in the "/Library/LaunchDaemons" directory.

I created a file called xampp.startapache.plist and put this inside:

<?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>EnableTransactions</key>
<true/>
<key>Label</key>
<string>xampp.startapache</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/XAMPP/xamppfiles/xampp</string>
<string>startapache</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/Applications/XAMPP/xamppfiles</string>
</dict>
</plist>

That was outlined here as well as on several other similar help pages. I've tried editing the files manually, and I've also tried using Lingon. But it just dosen't work! I've even tried doing a similar entry for a script file located in the same directory, which would echo the time to a log file. The log file is just blank - like the script is not being run.

How can I make this work?

share|improve this question
1  
Take a look at /Applications/Utilities/Console.app, the launchd error messages are usually helpful. Also, it could be a permissions issue, try making the plist owned by root. –  Daniel Beck Feb 9 '11 at 15:51
add comment

3 Answers

I suspect you're running afoul of launchd's expectations of the programs it launches. It's not primarily intended for things that need to just be run, it's for things that need to be run and kept alive -- so when xampp startapache finishes, launchd says to itself "OMG it exited, I'd better clean up the remains and start a new instance"... I haven't tested this with xampp, but I suspect that adding keys to the .plist to tell it not to restart (KeepAlive=false) and not clean up spawned subprocesses (AbandonProcessGroup=true) will do the trick:

<key>KeepAlive</key>
<false/>
<key>AbandonProcessGroup</key>
<true/>
share|improve this answer
    
I don't know. I had to actually put in two commands - one to start XAMPP, and then a separate one just to start mysql (/Applications/XAMPP/xamppfiles/xampp startmysql) and then it worked. –  cwd Mar 4 '11 at 15:14
add comment
up vote 1 down vote accepted

Here's what ended up working for me:

Create these two files:

/Library/LaunchDaemons/xampp.sql.startapache.plist
/Library/LaunchDaemons/xampp.startapache.plist

Inside the first one, add this code:

<?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>EnableTransactions</key>
<true/>
<key>Label</key>
<string>xampp.startapache.mysql</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/XAMPP/xamppfiles/xampp</string>
<string>startmysql</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/Applications/XAMPP/xamppfiles</string>
<key>KeepAlive</key>
<false/>
<key>AbandonProcessGroup</key>
<true/>
</dict>
</plist>

In the second one add this code:

<?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>EnableTransactions</key>
<true/>
<key>Label</key>
<string>xampp.startapache</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/XAMPP/xamppfiles/xampp</string>
<string>startapache</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/Applications/XAMPP/xamppfiles</string>
<key>KeepAlive</key>
<false/>
<key>AbandonProcessGroup</key>
<true/>
</dict>
</plist>

I had to have two because when I didn't have the sql one specifically mysql wasn't starting but apache was. This may be because I have SSL enabled or something weird like that. Anyhow, having both of them solved the problem for me, and I did use the Console.app to check for error messages when starting apache - that was helpful, too.

share|improve this answer
add comment

I had this same question myself, and while cwd's answer worked, it's overly complicated. I think the key is turning AbandonProcessGroup true. I have it working with this single launch daemon in OS X 10.9.

<?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>org.xampp.server</string>
  <key>ProgramArguments</key>
    <array>
      <string>/Applications/XAMPP/xamppfiles/xampp</string>
      <string>start</string>
  </array>
  <key>RunAtLoad</key>
    <true/>
  <key>AbandonProcessGroup</key>
    <true/>
  </dict>
</plist>
share|improve this answer
add comment

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.