Start or Stop Apache without having to give a password? On Ubuntu you can do something like this:

sudo adduser {username} www-data


That doesn't work on OS X, and may not be the best approach anyway.  On OS X, how can you make Apache start or stop without having to enter a password?
Open Terminal and enter sudo visudo to modify the file /etc/sudoers.

Change the part:

## User privilege specification
##
root ALL=(ALL) ALL
%admin  ALL=(ALL) ALL


to

## User privilege specification
##
root ALL=(ALL) ALL
%admin  ALL=(ALL) ALL
your_username ALL=(ALL) NOPASSWD: /usr/sbin/apachectl


and save the file.

If you don't know vi: after entering sudo visudo you have to change to insert mode by hitting i. Enter the additional line as indicated above. To leave insert mode hit esc. Then enter :wq and the Enter key to write the modified file to disk and quit vi.

Starting and stoping Apache with sudo apachectl start or sudo apachectl stop doesn't require a password anymore.



apachectl requires root/sudo to execute it. Only the root user can execute the command without entering a password. Neither adding a user to the admin group nor to another group (e.g. _www) allows to execute (sudo )apachectl without password.

So, the least intrusive method is adding a user - even a standard user - in the sudoers file and restrict the account to execute /usr/sbin/apachectl only. The added user is not allowed to execute any other command as sudoer!