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

Click here to return to the 'The Unix Way' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
The Unix Way
Authored by: escowles on Mar 08, '05 04:53:43PM

To allow starting of apache without a password hardcoded in a script (among the most insecure things you can do, btw), you should use sudo's NOPASSWD option. Use visudo to edit /etc/sudoers and add the line:

USERNAME ALL = NOPASSWD: /usr/sbin/apachectl
(you'll need to change USERNAME to your short username).

If you want all admin users to be able to restart apache without password, do:

%admin ALL = NOPASSWD: /usr/sbin/apachectl

Also, as another user pointed out, the startup items are only run when you login, not at boot. To run something when the machine boots, add it to your crontab using the @reboot keyword. Use crontab -e to edit crontab and add the line:

@reboot sudo /usr/sbin/apachectl graceful

Though at this point, you might just want to edit /System/Library/StartupItems/Apache to always startup apache, regardless of the config. I'm not sure what the bug is that makes it not work after a power failure, but just making the StartService function read:

apachectl start
would probably do the trick.


[ Reply to This | # ]