Starting XAMPP’s Apache Server at System Startup on Mac OS X


Until I recently switched to XAMPP I had been using MAMP to provide a local server environment on my Mac. A small but none the less important feature of MAMP is an option to have the Apache and MySQL servers started when you open the application. So, by checking this option and including MAMP as a Login Item my MAMP servers were up-and-running when I logged in. Unfortunately, XAMPP has no such option. Including XAMPP as a Login Item merely opens XAMPP and I have to start the servers manually. An extra step I’d rather not have to do.

So, how can I have my XAMPP servers running whenever I login? The answer, by using a daemon.


1. Daemons

Daemons in Mac OS X are system-wide services that are launched at system start-up. They are managed by a program named launchd which was first introduced in Mac OS X 10.4 Tiger. Services that are run on a per-user basis are known as agents, but are still managed by launchd. From a user’s perspective, launchd replaces the more traditional cron.

To have launchd start XAMPP’s Apache server as a service we need to create a launchd configuration file. This configuration file has a .plist extension, a format familiar to many Mac OS X users. launchd configuration files can be placed in one of three folders determining when and for whom the service will start.

  • System startup [all users]:  /Library/LaunchDaemons/
  • User login [all users]:  /Library/LaunchAgents/
  • User login [this user only]:  ~/Library/LaunchAgents/


2. What You’ll Need

Any text editor will allow you to create the necessary configuration file, but you’ll be asked to authenticate if saving the file in either the /Library/LaunchDaemons/ or /Library/LaunchAgents/ folders. You can use a text editor like Smultron by Peter Borg which will allow you to authenticate. I’m sure there are others. There’s also a great little app called Lingon, coincidentally by the same author, which makes the whole configuration a snap. Whilst both Smultron and Lingon are free they’re unfortunately no longer being developed. However, the latest (last?) versions of both run fine under Mac OS X 10.5.8 Leopard Mac 0S X 10.6.2 Snow Leopard.


3. Creating the launchd Configuration File

The configuration file I’m going to create will start XAMPP’s Apache server as a service at system startup. In Terminal I’d type /Applications/XAMPP/xamppfiles/xampp startapache to start XAMPP’s Apache server, so this is the command I’ll include in my configuration file. There are other options available, but I’m only concerned with starting Apache. A full list of parameters can be found here.

If you’re using the standard Apache port 80 in XAMPP or any non-standard port below 1024 then you’ll need to place the configuration file in the /Library/LaunchDaemons/ folder. This is because XAMPP requires authentication to use ports below 1024 and a configuration file in the /Library/LaunchDaemons/ folder will run as root. If you place the configuration file in either of the other two folders it won’t be able to authenticate and the Apache server won’t start.

To start creating the configuration file, open Lingon and click the New button at the top-left corner.

Launch daemon selection in Lingon

Launch daemon selection in Lingon



Lingon will ask where you want to create the configuration file. Select Users Daemons and click Create.


Launch daemon configuration in Lingon

Launch daemon configuration in Lingon



To configure the LaunchDaemon we need to do just 4 things:

  • 1. Ensure the Enabled option is checked. If later you wish to disable the LaunchDaemon simply uncheck this option.
  • 2. Enter a name for the configuration. I’ve called mine apachefriends.xampp.apache.start. Lingon will add the .plist extension for you.
  • 3. Enter the command, as you would in Terminal, to start Apache. This is /Applications/XAMPP/xamppfiles/xampp startapache
  • 4. We’re only concerned with the Run it when it is loaded by the system (at startup or login). All other options should remain unchecked.

That’s it. Save the file and you’re done. Whenever you reboot your Mac, XAMPP’s Apache server will be up-and-runing when you log-in. If you navigate to the /Library/LaunchDaemons/ folder you’ll now see the apachefriends.xampp.apache.start.plist file.

At the bottom right-hand corner of the Lingon window there’s an Expert Mode button. If you click this button you’ll see the configuration file that Lingon’s created. It should resemble this:

Dummy Content
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
As an alternative to creating the configuration file with Lingon, simply copy and paste the code block above into a text editor and save the file as apachefriends.xampp.apache.start.plist in the /Library/LaunchDaemons/ folder.


4. Adding XAMPP Login Items

This step is optional and only for the terminally lazy like me. If you want XAMPP opened when you login simply add it to the Login Items in System Preferences > Accounts > your account > Login Items and set it to Hide.


These instructions are only for Leopard and Snow Leopard using XAMPP 1.7.2a. There appears to be an issue with the method described here if you’re using XAMPP 1.0.1 with Snow Leopard (and possibly Leopard). See the Comments section below for a possible workaround.

About the author

A native Brit exiled in Japan, Steve spends too much of his time struggling with the Japanese language, dreaming of fish & chips and writing the occasional blog post he hopes others will find helpful.

12 responses


  • I put the file in the daemon folder after days of frustration and trying all sort and it worked. I’m very grateful to your old blog here, Steve – and you, haha.
    So, I came back to say thanks and quell surprise. I’m also Steve, I also live in Japan (albeit the southern-most Pref, I cook fish and chips on occasion and read blogs that I find helpful! We could be brothers! Kind of? You being the smarter one I suppose. That means I get the looks? haha. I arrived in 2009, and am still struggling to pass my N4.
    Won’t give up though. Same goes for my site. Cheers mate!

  • You’re welcome.

    Out of interest I did get Apache started using 10.6.2 and a vanilla install of XAMPP 1.0.1 by replacing the appropriate code in the configuration file with


    apachectl start is actually the command executed by ../xampp start and ../xampp startapache.

    This of course only starts Apache. I started FTP using a separate configuration file with


    However, I didn’t have any luck starting MySQL using launchd with XAMPP 1.0.1. Commands that worked in Terminal simply failed with launchd. The logs point to a permissions issue. The only way I could get MySQL to start was to include an AppleScript as a Login Item:

    tell application “Finder”
    set theCommand to “/Applications/XAMPP/xamppfiles/xampp startmysql”
    do shell script theCommand password “password” with administrator privileges
    end tell

  • It’s actually the latest – but I have a weird of combo of 1 and 1.7 since I need(ed) to run php – maybe that was an issue. Anyhow – snow leopard has a nice php build finally with many extensions and mysql has a dmg for 64 bit so I switched back to native and it was a breeze. Much better than what came with leopard/tiger.

    Thanks for your help

  • Hi Joshua,

    I used your launchd configuration file as-is with XAMPP 1.7.2a and all three servers started.

    My system log:

    06/12/2009 08:06:06 apachefriends.xampp.apache.start[78] Starting XAMPP for Mac OS X 1.7.2a...
    06/12/2009 08:06:06 apachefriends.xampp.apache.start[78] XAMPP: Starting Apache...
    06/12/2009 08:06:07 apachefriends.xampp.apache.start[78] ok.
    06/12/2009 08:06:07 apachefriends.xampp.apache.start[78] XAMPP: Starting MySQL...
    06/12/2009 08:06:07 apachefriends.xampp.apache.start[78] ok.
    06/12/2009 08:06:07 apachefriends.xampp.apache.start[78] XAMPP: Starting ProFTPD...
    06/12/2009 08:06:07 apachefriends.xampp.apache.start[78] ok.

    You said in your initial post that you’re using the latest version of XAMPP, but the first line of your system log shows XAMPP 1.0.1.

    So I installed XAMPP 1.0.1 and ran your launchd configuration file again and got the same errors you’re getting.

    My system log:

    06/12/2009 08:19:43 apachefriends.xampp.apache.start[78] Starting XAMPP for MacOS X 1.0.1...
    06/12/2009 08:19:48 apachefriends.xampp.apache.start[78] XAMPP: Starting Apache...
    06/12/2009 08:19:48 apachefriends.xampp.apache.start[78] XAMPP: [1mError 127! Couldn't start Apache![m
    06/12/2009 08:19:48 apachefriends.xampp.apache.start[78] XAMPP: [1mStarting diagnose...[m
    06/12/2009 08:19:48 apachefriends.xampp.apache.start[78] XAMPP: [1mSorry, I've no idea what's going wrong.[m

    Using XAMPP 1.0.1, if I run sudo /Applications/XAMPP/xamppfiles/xampp start from Terminal all three servers start as expected, but if I try to load the configuration file from Terminal: sudo launchctl load /Library/LaunchDaemons/apachefriends.xampp.apache.start.plist I get the same errors for Apache. So, the problem is with the configuration file and XAMPP 1.0.1.

    I’ll take a look and see if there’s a workaround for this, but you may want to consider upgrading to XAMPP 1.7.2a.

  • Here it is.. Also my system log shows the failure as
    Dec 5 08:28:13 Null apachefriends.xampp.apache.start[3504]: Starting XAMPP for MacOS X 1.0.1…
    Dec 5 08:28:13 Null apachefriends.xampp.apache.start[3504]: XAMPP: Starting Apache…
    Dec 5 08:28:13 Null apachefriends.xampp.apache.start[3504]: XAMPP: ^[[1mError 127! Couldn’t start Apache!^[[m
    Dec 5 08:28:13 Null apachefriends.xampp.apache.start[3504]: XAMPP: ^[[1mStarting diagnose…^[[m
    Dec 5 08:28:13 Null apachefriends.xampp.apache.start[3504]: XAMPP: ^[[1mSorry, I’ve no idea what’s going wrong.^[[m







  • Hi Joshua,

    Could you post your launchd configuration (.plist) file and tell me what port you’re using for Apache? I’ll test it on my setup.

  • Yes I have the same issue. 10.6.2 – latest xampp – starts fine from terminal but does not seem to work like this.

  • Hi Alister,

    I’m using 10.6.2 and XAMPP 1.7.2a which appears to be the latest version released this August.

    Have you tried starting Apache from Terminal by typing sudo /Applications/XAMPP/xamppfiles/xampp startapache?

    Terminal should respond with something like XAMPP: Starting Apache…ok.
    If not, take a look at the Apache error log in /Applications/xampp/xamppfiles/logs/error_log for any clues.

    I’m going to run through my instructions again, but your issue may be due to the version of XAMPP you’re using.

    Let me know how you get on.

  • I’ve been trying to do the same thing – without success – in Snow Leopard using XAMPP 1.0.1.
    Which OS and version of XAMPP are you using?


Recent Comments

Recent Posts