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.)
3 Answers
The thread Starting Xampp Control Panel without password lists two possible solutions :
- Write scripts that start and stop XAMPP, specifying the password in the scripts.
The two scripts are included in the thread. - Edit the
/etc/sudoersfile, configuring thatsudo /Applications/XAMPP/xamppfiles/xampp startdoesn't need a password.
- 498,455
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:
- Open Terminal.app (I like to hit Command+Space, then type "Terminal.app", then hit Enter).
- Run
sudo nano /etc/sudoers. Append the following text to the file, where username is your short username (type
whoamiinto the terminal to get it):- For option a:
%username ALL=(ALL) NOPASSWD- For option b:
%username ALL= NOPASSWD: /Applications/XAMPP/xamppfiles/xamppPress Ctrl+x, and save when prompted.
Note that on OSX Mavricks, you may have to add a % sign before the username (in /etc/sudoers).
- 1,816
macOS High Sierra
In High Sierra I couldn't get the new control app manager-osx working without entering password, even when adding it in sudoers.
But you can run xampp from command line to start and stop xampp (or only apache) without password, if you add it to the sudoers file.
But: The solutions above made problems for me, so here what I did:
Do not edit /etc/sudoers/ file, many things can go wrong! If you really want, use sudo visudo
macOS also will not allow to use vim sudoers (you cannot save), at least with activated SIP.
Better approach
Create a new file in the directory /etc/sudoers.d. You need root rights to create the file.
Name the file like your username (for example). No extension needed.
Filename doesn't really matter, but it must not cotain a ~ at end or a dot (.) at beginning.
In this new file create only the needed entries, but DON'T add a % in front of your username. This didn't work for me and every call of sudo took a long time before asking the password.
Content of the new file:
username ALL = NOPASSWD: /Applications/XAMPP/xamppfiles/xampp
Now you can run
sudo /Applications/XAMPP/xamppfiles/xampp start
in a Termin to start xampp and you don't have to enter your password.
If something goes wrong
Delete all your entries in the sudoers or the new file, or comment them with double ## so sudo will ignore them.
Try this, if file is completely broken: https://astrails.com/blog/2009/09/29/how-to-fix-a-hosed-etc-sudoers-file-on-mac-osx
If nothing else works, reboot to single user mode and repair the file. There should also be a backup in /etc called sudoers~orig.
- 155
- 5