1

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?

1
  • 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, 2011 at 15:51

4 Answers 4

2

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.

1

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/>
1
  • 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, 2011 at 15:14
0

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>
0

This worked for me : first anwser of mipadi finnaly solved my problem https://stackoverflow.com/questions/8014500/macosx-autostart-mysql-on-boot I first did this localhost/dashboard/docs/auto-start-xampp.html Then started my sql by doing this

mkdir -p ~/Library/LaunchAgents
cp `brew --prefix mysql`/*mysql*.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/*mysql*.plist

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .