Apache: apachectl restart does NOT reload envvars

apache-2.2ubuntu-12.04

Okay, so on a fresh ubuntu 12.04, I install the lamp stack via:
sudo tasksel install lamp-server

The next thing I want to do is change the User and Group that apache runs as and restart.
Should be easy, right? WRONG.

Apache is installed such that it gets the User and Group from /etc/apache2/envvars
I edit this file and change the User and Group, then do "apachectl restart" and… nope, the old User and Group are still in use (as confirmed via phpinfo). But if I do "apachectl stop" followed by "apachectl start" THEN it works. However, this sucks because I'm trying to write a bootstrap.sh script for Vagrant, and neither of these methods work in that context (I guess stop/start happens too fast, so while "stop" works, "start" does not.

In a perfect world, "restart" would do its job and actually reload the new values from envvars. Any ideas??

Best Answer

In an ideal world people would read the documentation :-)

http://httpd.apache.org/docs/2.2/stopping.html#hup

Signal: HUP

apachectl -k restart

Sending the HUP or restart signal to the parent causes it to kill off its children like in TERM, but the parent doesn't exit. It re-reads its configuration files, and re-opens any log files. Then it spawns a new set of children and continues serving hits.

Since the parent is not restarted, you can't use a restart to change the user it is running under.