Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What's the best way to bring down an apache2/tomcat6 setup for maintenance? Specifically, apache2 can stay running, but tomcat needs to restart to accomplish a number of tasks. My initial thought is to change the root directory in the httpd.conf VirtualHost entry to point to a new location, then issue a force-reload command to direct traffic away from the actual tomcat application. After some period of time, I perform tomcat maintenance, switch the VirtualHost entry, and force-reload to begin directing traffic back.

Is there a better way to do this? I'm looking to start work on a rather extensive web application, and my deployment procedure right now involves shutting everything down and bringing everything back up. Is there a better way to do this than what I've proposed?

share|improve this question
this is the best option, imho. – Marco Ramos May 25 '10 at 18:34
up vote 2 down vote accepted

It's either what you described above or if you have a load balancer and a second server somewhere you can re-route the traffic at the LB to point at the spare server (serving a static "Hey, we're doing maintenance! Come back later!" page).

The advantage of handling the maintenance window on a load balancer (or by IP-swapping the second server) is that you can test your Tomcat stack end-to-end before pointing live traffic at it again, which avoids unpleasant surprises where some bit of configuration from the dev environment snuck into production.

share|improve this answer

I see somewhere a rewrite to do so :

ErrorDocument 503 "Our website is temporarily closed for maintenance. It should reopen by..."
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^111\.222\.333\.444$
RewriteRule .* - [R=503,L]

The IP 111.222.333.444 is your IP adress to access to your site. All other users will be redirect to 503 ErrorDocument. Put all of this in a .htaccess at the root of your virtualhost.

I don't know if it works with tomcat, but it works with static or PHP pages. Of course, Apache must be configured to read .htaccess file

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.