Httpd – Proper steps for updating Apache conf on production server

apache-2.2httpdmod-rewrite

I usually:

  1. Update my local near-replica ( ServerName directive and Logs will obviously be different ) of the production conf file and make my changes for things like rewrite rules.
  2. /etc/init.d/apache2 restart or graceful locally and ensure it's working
  3. scp the conf file to the production server
  4. apache2ctl configtest
  5. apache2ctl graceful

I never really followed any sort of guide, just picked up some commands. Is this usually the way it's done? I almost always use graceful on the production server since I don't want to lose clients with a full restart – graceful restarting is fairly common, right? Are there any circumstances where graceful isn't sufficient and I need to do a full restart?

Best Answer

It depends on the scale you're at -- you've got the basic steps down, the main differences would be in how the config file is propagated to the production servers (bigger sites would involve things like checking it into revision control and waiting for or forcing Puppet, Chef, CfEngine, etc. to propagate the change out) and the degree of automation that is used (again, bigger sites hopefully have more automated procedures, since they'll be dealing with more than one server).

AS for graceful versus hard restart -- in the graceful, the "main" Apache parent process doesn't exit, just the worker child processes. I've seen circumstances where the primary process had some sort of cached state -- old DNS, whatever -- that didn't get flushed with a graceful, only a full stop/start cycle.