Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have several website stored on a server.

If I want to upgrade my apache configuration I want to inform all my customers that there will be an upgrade in 30 minutes.

I can modify each website to show this message but I was wondering, how can I make it automatic ? What's the professional way to do it ?

Also, when Apache is restarting or upgrading, there will be no "Maintenance page". How can I instead show for each website a default page "under upgrade" if apache is down ? Do I need 2 servers ?

share|improve this question

4 Answers 4

up vote 2 down vote accepted

During the phase where you upgrade all your packages, you just keep apache running and nobody will notice.

The actual restart of apache can be done in such a manner that individual users won't notice that either, by using a graceful restart. This will allow each worker thread to complete serving the current page and then not accept new requests. Then the server reload, which only takes a few seconds, and starts serving requests again.

That's not your problem. The problem is what to do if something does go wrong. In which apache won't restart, and the n your user will notice. So you want to make sure that nothing can go wrong.

And the way to do that is to create an exact mirror copy of that web server on another machine, then do the upgrade there and see what happens. Make a note of all the things that need a manual fix or intervention before apache is restarted. Then repeat the whole process until you have a completely smooth operation. And then and only then you do the upgrade on the live server.

share|improve this answer
    
What if my customers are filling an e-commerce form which has 2 or 3 pages as steps and apache restart gracefully while they are filling the form. Isn't that an issue ? thanks –  Patrick Sep 30 '10 at 9:56
    
Well, that depends heavily on how your sites handle sessions. If the sessions are handled with cookies and database entries, then all should be fine. If not, all sorts of funny (i.e. strange) things can happen. –  wolfgangsz Sep 30 '10 at 11:42
    
Assuming you're using say PHP sessions, it's not an issue. The session value in the cookie just tells the server which session data to load for this connection. That won't change, so it will be fine. Most session systems use something similar to this. it's definately worth some testing first. and I just have to reitterate wolgangsz comment, MIRROR AND TEST!!! it's the only way to be as close to sure as you can be... –  BParker Apr 28 '11 at 9:26

I want to inform all my customers that there will be an upgrade in 30 minutes.

You need some additional capability over just serving static content - you could do this using server side includes or a PHP auto-prepend or roll your own solution using the language you develop your site in. Then just change the content of the file you are including. However this is not a trivial exercise - to support this you would need to ensure that html content served is non-cacheable (or has a very short cache time). Also, if you use the PHP route you can't just write the output straight to the browser if you need to use cookies / sessions / redirection.

when Apache is restarting or upgrading, there will be no "Maintenance page". How can I instead show for each website a default page "under upgrade" if apache is down ?

This is much MUCH more complicated. Given that restarting your Apache instance shouldn't take more a few seconds its not worth the effort. If the restart takes more than 5 seconds, then you've got a different problem to fix.

share|improve this answer
    
Ok, one more thing: if I add some php statements to all my websites with the warning message, is there a way I can enable it for all websites automatically, instead of changing the parameter for each website, one by one ? –  Patrick Sep 30 '10 at 9:59

There are any number of ways to do this, but I might make a recommendation to do this with Javascript.

You could embed a script on each site at any time. Have the script check a URL on your server, it can be simply a text file with a 0 or 1, or you can put a message in there (JSON is a good protocol to use). Have the script, client side, check a URL for that variable. If it is 1, display the message, if it is 0 do not. You might even want to encode the message in that text file in case you need to display some message to all of your website users about a delay or any other information.

When you are ready to make the migration, 30 minutes prior, have the Javascript launch a notification bar at the top of the sites, notifying users that the site will be upgraded shortly.

You can get as fancy as you want with it, but in my head this is the best way to do this for a number of sites. Of course, if you have a lot of hits at any one time, that is a lot of clients checking that URL. It just depends on your particular situation. You could also do it server-side with some caching.

share|improve this answer
    
So,what is not clear to me is how to automatize the process. For example, ok.. I can add the same script to all my websites, and then I should append a variable to all urls by default with Apache to pass this parameter to enable the javascript scripts ? –  Patrick Sep 29 '10 at 14:29

You can use mod_layout to add custom HTML or PHP code to the start or end of pages. See the mod_layout FAQ for a good overview of how to use the mod but it can be as simple to use as:

<VirtualHost www.foo.com:80>
    LayoutFooter "Insert some sort of message here..."
</VirtualHost>
share|improve this answer

Your Answer

 
discard

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.