Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I display a maintance message

Status
Not open for further replies.

DRapper

Programmer
Nov 25, 2003
18
0
0
US
Hello All,

How would I display a message stating that my server is down for maintance?

DRapper
 
If the machine or apache will not be running, then there isn't any way to do it locally. Setup an http server on another machine on your local net or some other location. It only has to serve one page so it doesn't have to be anything fancy. If this backup server is on your lan, just have your router forward all http traffic to that machine. If it is at a remote site, you will need to setup dns to do web fowarding to another address. Many dns services allow you do cloaking so that even though you are forwarding to one of those free websites with a long name, your visitors will not see that. If you host more than one site, avoid any mention of a particular domain since all domains will be sharing the same page. If you are just talking about one site, you just need to create a page called maint.html and put it in your document root. Edit httpd.conf and add "main.html" to the line that starts with the directive DirectoryIndex. Add maint.html BEFORE index.html because apache will look for these in the order they are here. When you're done editing, restart apache. When you are done with your maintenance, just remove or rename the maint.html file. You won't need to edit httpd.conf or restart the server because if apache doesn't find maint.html it just moves to the next one on the list which is index.html.
 
RhythmAce

Thanks for your Help.

DRapper
 
Actually, you can add start directives to apache. We do this all the time. To do this you have to update apachectl and your httpd.conf.

Here is our example:

apachectl

---
startdown)
$HTTPD -D DOWN -k start
ERROR=$?
;;
----

This adds the '-D DOWN' option to the apache startup. You can then catch this in your httpd.conf. Here is how we do it

httpd.conf
-----
<IfDefine DOWN>
RewriteRule ^/.*$ /error/maint.html
</IfDefine>

<IfDefine !DOWN>
...your normal configurations here
</IfDefine>
-----

So IF the -D DOWN option is set via 'apachectl startdown' this catches that and rewrites all requests to /error/maint.html.

This works great for us. It allows us to bring down our front-end servers in a calm manner during emergencies.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top