Mac OS X - fire up Apache/Mysql without prompting for password

I am running XAMPP which comes with a little "XAMPP Control" app that lets me start and stop Apache and MySQL by clicking a button. When I do that, I'm prompted by Lion for my admin password. Is there a way to skip this step? (On Windows, this is sort of like me asking "how can I run the XAMPP Control program in administrator mode?" --not sure if there's an analog for Mac.)


Problem

Mac OSX asks you for your password because XAMPP is trying to run the *nix command [sudo](http://en.wikipedia.org/wiki/Sudo). This can be overcome by one of two ways:

a. Allow ALL sudo commands to be run without a password.

b. Allow ONLY the XAMPP command to be run with no password.

Solution

To use one of these solutions, do the following:

  1. Open Terminal.app (I like to hit Command+Space, then type "Terminal.app", then hit Enter).
  2. Run sudo nano /etc/sudoers.
  3. Append the following text to the file, where username is your short username (type whoami into the terminal to get it):

    • For option a:

    %username ALL=(ALL) NOPASSWD

    • For option b:

    %username ALL= NOPASSWD: /Applications/XAMPP/xamppfiles/xampp

  4. Press Ctrl+x, and save when prompted.

Note that on OSX Mavricks, you may have to add a % sign before the username (in /etc/sudoers).


The thread Starting Xampp Control Panel without password lists two possible solutions :

  1. Write scripts that start and stop XAMPP, specifying the password in the scripts.
    The two scripts are included in the thread.
  2. Edit the /etc/sudoers file, configuring that sudo /Applications/XAMPP/xamppfiles/xampp start doesn't need a password.