Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Automatically start Xampp at login Apps
I like xampp a lot, because it's a complete package. I used to configure the whole thing myself on the Mac, but it took a lot of time. Xampp, on the other hand, is just so easy to configure and install. The biggest problem I had was that Xampp has to be started manually, and this is bad because I use my Mac mini as a demo server to show my work to customers before going live. If there is a power failure and I am not around, the server won't start. After some head scratching, obfuscated further by reading too much on the net, I found an obvious and simple solution.

All I needed to do was to write this very simple Applescript:
do shell script "sudo /Applications/xampp/xamppfiles/mampp start" password "YOUR ADMIN PWD" with administrator privileges
Save this as an application, put it in the Documents folder, then add it to System Preferences » Accounts » Login Items. Voila, restart you Mac, and your web pages are served.
    •    
  • Currently 3.00 / 5
  You rated: 5 / 5 (6 votes cast)
 
[23,714 views]  

Automatically start Xampp at login | 8 comments | Create New Account
Click here to return to the 'Automatically start Xampp at login' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically start Xampp at login
Authored by: spicyj on Jun 18, '08 07:46:34AM
You shouldn't need "sudo". This should work just fine:
do shell script "/Applications/xampp/xamppfiles/mampp start" password "YOUR ADMIN PWD" with administrator privileges
If you edit the sudoers file properly, though, then you shouldn't need to put your password in a file for everyone to see.

[ Reply to This | # ]
Couldn't you use launchd?
Authored by: jecwobble on Jun 18, '08 08:46:06AM

Seems like that would be a more elegant method of starting it and keeping it running.



[ Reply to This | # ]
Couldn't you use launchd?
Authored by: pauldy on Jun 18, '08 12:08:18PM

I agree this is an ok hack to get fro point a-b and for your specific situation it might suit you perfectly but you should really read up on launchd for this and pull this hint before someone hurts themselves with it.



[ Reply to This | # ]
Couldn't you use launchd?
Authored by: MacOrNothing on Jun 27, '08 08:55:55PM

"this hint before someone hurts themselves with it."

Gees, I have never claim this is the best solution and no one is forced to used this hint if it doesn't suite him.

If you have a better solution why don't you post it and share instaed of barking?



[ Reply to This | # ]
Automatically start Xampp at login
Authored by: thespider on May 03, '09 11:42:55AM
Almost a year later, another way to start: Using OS X 10.5.6 and XAMPP 1.0.1

To start XAMPP using Launchd, all you have to do is create a text file using something like TextWrangler or BBEdit in /Library/LaunchDaemons/ named: org.apachefriends.xampp.plist

in this text file enter this text:

<?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>KeepAlive</key>
	<true/>
	<key>Label</key>
	<string>org.apachefriends.xampp</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Applications/XAMPP/xamppfiles/xampp</string>
		<string>start</string>
	</array>
	<key>QueueDirectories</key>
	<array/>
	<key>RunAtLoad</key>
	<true/>
	<key>WatchPaths</key>
	<array/>
</dict>
</plist>
Set the permissions on the file to:
Owner: root Group: wheel
Owner: read+write Group: read Others: read

Restart your machine and XAMPP should start all services.

Or, you can start the launchd item with this terminal command
type in terminal:
launchctrl load /Library/LaunchDaemons/org.apachefriends.xampp.plist

This launchd item will also keep your site running, should something accidently quit or exit.

You can also use Lingon to create this LaunchD item. Use this command in Lingon to start XAMPP:
/Applications/XAMPP/xamppfiles/xampp start

Check this site for different startup command possibilities:
http://www.apachefriends.org/en/xampp-macosx.html#903

Full steps from the terminal to create this launchd item are as follows:

Open Terminal
type:
sudo -s
Enter your password (you need to be an admin)
type:
cd /Library/LaunchDeamons
type:
vi org.apachefriends.xampp.plist
hit the "i" key
paste this text in:

<?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>KeepAlive</key>
	<true/>
	<key>Label</key>
	<string>org.apachefriends.xampp</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Applications/XAMPP/xamppfiles/xampp</string>
		<string>start</string>
	</array>
	<key>QueueDirectories</key>
	<array/>
	<key>RunAtLoad</key>
	<true/>
	<key>WatchPaths</key>
	<array/>
</dict>
</plist>

hit the "esc" key, then ":", then "wq" and hit return
Now type:
launchctrl load /Library/LaunchDaemons/org.apachefriends.xampp.plist

Check your XAMPP control app and you should see that they are running. Test it out by stopping apache, mysql, or ftp from the XAMPP Control. After a minute or so, it should auto start your processes and will reflect that change in the XAMPP application.

Hopefully I didn't miss anything, let me know if I did, or if you need help.
Rusty

[ Reply to This | # ]
Automatically start Xampp at login
Authored by: cicciokun on Sep 11, '09 06:24:31AM
excellent tutorial, but it's "launchctl" ;)

[ Reply to This | # ]
Automatically start Xampp at login
Authored by: mugginsoft on Oct 14, '09 03:44:39AM
Under 10.6 launchd seems to object. Console reports;

14/10/2009 11:43:19 org.apachefriends.xampp[5182] XAMPP: Starting Apache...
14/10/2009 11:43:19 com.apple.launchd[1] (0x10011d740.anonymous.nohup[5197]) Bug: launchd_core_logic.c:8250 (23932):0
14/10/2009 11:43:19 com.apple.launchd[1] (0x10011d740.anonymous.nohup[5197]) Switching sessions is not allowed in the system Mach bootstrap.
14/10/2009 11:43:19 com.apple.launchd[1] (0x10011d740.anonymous.nohup[5197]) _vprocmgr_switch_to_session(): kr = 0x44c
14/10/2009 11:43:19 org.apachefriends.xampp[5182] XAMPP: Error 127! Couldn't start Apache!
14/10/2009 11:43:19 org.apachefriends.xampp[5182] XAMPP: Starting diagnose...
14/10/2009 11:43:19 org.apachefriends.xampp[5182] XAMPP: Sorry, I've no idea what's going wrong.
14/10/2009 11:43:19 org.apachefriends.xampp[5182] XAMPP: Please contact our forum http://www.apachefriends.org/f/
14/10/2009 11:43:19 org.apachefriends.xampp[5182] XAMPP: XAMPP-MySQL is already running.
14/10/2009 11:43:19 org.apachefriends.xampp[5182] XAMPP: XAMPP-ProFTPD is already running.
14/10/2009 11:43:19 org.apachefriends.xampp[5182] XAMPP for MacOS X started.

[ Reply to This | # ]
Automatically start Xampp at login
Authored by: zonesny on Jan 28, '13 12:45:31PM

FWIW, I finally got both XAMPP apache and XAMPP mysql installs to run automatically on start up (I'm using OS 10.5.8 Leopard). These two posts set me in the right direction (very grateful to original posters!):

http://hints.macworld.com/article.php?story=20080128103022907

AND

http://hunterford.me/mysql-startup-item-for-mac-os-x/

To start Xampp's Apache Server, I created the following daemon (this .plist file should be placed in the Library/LaunchDaemons/ folder):


<?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>XAMPP APACHE START</string>
	<key>ProgramArguments</key>
	<array>
		<string>/applications/xampp/xamppfiles/xampp</string>
		<string>start</string>
	</array>
	<key>QueueDirectories</key>
	<array/>
	<key>RunAtLoad</key>
	<true/>
	<key>WatchPaths</key>
	<array/>
</dict>
</plist>

To start Xampp's mysql install, I created the following daemon (again place this .plist file in the Library/LaunchDaemons folder):


<?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>XAMPP MYSQL START</string>
	<key>Disabled</key>
	<false/>
	<key>GroupName</key>
	<string>_mysql</string>
	<key>KeepAlive</key>
	<true/>
	<key>Program</key>
	<string>/Applications/XAMPP/xamppfiles/bin/mysqld</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Applications/XAMPP/xamppfiles/bin/mysqld</string>
		<string>--user=_mysql</string>
	</array>
	<key>QueueDirectories</key>
	<array/>
	<key>RunAtLoad</key>
	<true/>
	<key>Umask</key>
	<integer>7</integer>
	<key>UserName</key>
	<string>_mysql</string>
	<key>WatchPaths</key>
	<array/>
	<key>WorkingDirectory</key>
	<string>/Applications/XAMPP/xamppfiles</string>
</dict>
</plist>

    A couple of important notes:
  • The owner of these plist files needs to be "root" and the group needs to be "wheel" [in terminal type: sudo chown root:wheel XAMPP MYSQL START.plist and sudo chown root:wheel XAMPP APACHE START.plist]
  • Permissions should be 644. [in terminal type: chmod -644 for each file]
  • While apache and mysql will run correctly at startup, the actual "xampp control app" will still show a "red light" for mysql.
  • To stop mysql, go to the mac terminal type: top -u. This will show you the running processes. Look for the PID number of the mysqld process, press q, then type: kill [PID] (i.e. kill 123, or kill -123 to force quit).

This information was very difficult to locate for some reason. I hope it saves someone a lot of wasted time! ;)



[ Reply to This | # ]