Posts Tagged ‘administration’

For Robomen: “Website is Under Construction. Please Come Back Later”

Friday, December 26th, 2008

Iteratively developed web projects are constantly updated. Sometimes the file structure has to be changed. Sometimes a new table is added to the database schema. Sometimes the data has to be massively changed. In a simpler case, HTML templates and style is changed. Usually, a more complex upgrade takes half an hour or even an hour, and the visitors should see “Under Construction” page instead of the normal site during the process, because the nobody should see broken view or corrupt data by accident while writing something to the database at that time.

Under Construction

A good practice for Apache web server users is to have a couple of configuration files which would be activated alternately, depending on whether the website is accessible to everyone, or is in the upgrade state. Once Tomas gave me an idea to create such configuration for the upgrade cases that others saw “Under Construction” page and I could browse the content and test if everything looks alright. So did I.

Apache lets you set the web server configuration on the directory level using .htaccess files. For the important projects I have files .htaccess_live and .htaccess_under_construction containing different settings in the root directory of the website. When I need to change the state, I copy the appropriate configuration to the .htaccess file:

cp .htaccess_under_construction .htaccess

or

cp .htaccess_live .htaccess

The content of the Apache configuration file .htaccess_live is something like this:

# index.html and index.php represents the directory by default
DirectoryIndex index.html index.php
<ifmodule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    # If the page was accessed by example.com, then redirect the request to www.example.com
    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]
</ifmodule>

Whereas the content of .htaccess_under_construction is this:

# index.html and index.php represents the directory by default
DirectoryIndex index.html index.php
<ifmodule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    # If the page was accessed by example.com, then redirect the request to www.example.com
    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]

    # if the IP address of the visitor is not 1.2.3.4 and the requested directory is not media,
    # then redirect the request to the file temporarily-offline.html
    RewriteCond %{REMOTE_HOST} !^1\.2\.3\.4
    RewriteCond %{REQUEST_URI} !/temporary-offline\.html$
    RewriteCond %{REQUEST_URI} !^/media
    RewriteRule .* /temporary-offline.html [R=302,L]
</ifmodule>

These configurations use the mod_rewrite module. RewriteCond defines the conditions which should be met to execute the redirect of request set by RewriteRule. The parameters in the brackets have the following meaning:

  • NC (no case) – use case insensitive comparison.
  • R=301 – redirect the request with code 301 “Moved Permanently”.
  • R=302 – redirect the request with code 302 “Moved Temporarily”.
  • L (last rule) – this is the last rule, so don’t execute the rest.

You can find your own IP address in one of the plenty What’s My IP services.

Now it’s clear how to technically set the temporary “Under Construction” view. The next thing, which seems quite important to me, is to show an appropriate temporary page. I personally like such error and system-message pages which describe the problem in a non-technical and visual way like twitter.com does, or the ones showing a video or something interactive to make me busy while the upgrade is being done.

Ugly Linux Server Administration

Wednesday, January 25th, 2006

Will the word “Prerequisites” ever become my friend? Whenever I need to install something to a Linux-based server, I will certainly find an article which name is the mentioned word, in the documentation of the software that is going to be installed. “Prerequisites” means “software that is required to be installed before the installation of your wanted software”. And usually the prerequired software is never installed in the server. Usually prerequisites have their own prerequisites. So you have to go hopelessly through the tree of requirements deeper and deeper and install everything they say. Why can’t there be automatic installers that when necessary would install those prerequisites to the server themselves?

New Job. New Impressions. Drupal.

Monday, November 7th, 2005

Last week I started working in Berlin. I am a programmer at the design company, called Studio 38, Pure Communication Ltd. I’ve got an Apple Cube and got a task to familiarize myself to Drupal, which is a Content Management System Construction Kit (CMSCK).

First off all, Mac OS, which is perhaps the only Operating System for Apple Computers, was new to me and I had to learn the differences between it and the other operating systems that were already known to me.

I prepared my working place for work installing and configuring the Java-based text editor JEdit and the Firefox browser. I familiarized myself with the common Mac OS keyboard shortcuts and mouse behavior that will speed up my work. I got familiar with MAMP that stands for Mac OS plus Apache plus MySQL plus PHP.

Druplicon Then I read much about Drupal. Drupal community has a large web portal drupal.org, which is, btw, powered by Drupal itself. The CMSCK is dedicated to the portals of large communities. It was created in order to exchange information among friends studying at some Holland University and later it grew up into an open source project, developed by programmers all over the world.

One of the unusual features of Drupal is that it has the same user interface for the site as well as for its administration. A man should consider, that every visitor or user of the Drupal-based site belongs to some role and has permissions dedicated to that role. A Drupal-based web portal is like a living creature fed with information by its users.

I installed different versions of Drupal, found, corrected and reported some bugs, and learned some good practices as separating live site and testing site. You should do all the changes on the testing site before upgrading the live site. The testing site should be a duplicate of the live site.

Drupal has a set of terms that a developer of Drupal-based site should know. One of the most unusual terms is ‘taxonomy’. Taxonomy lets you categorize your content. At first, you create categories and insert terms like in a dictionary. Then you assign the terms to the entities of your content called nodes. Considering usability, the worse thing is that if you want a dynamical menu built on some branch of taxonomy, you have to code that menu yourself or to use some third-party modules.

The core implementation of Drupal doesn’t let you assign various templates to different pages or sections. If you want to have several templates you should modify your theme inserting some conditional statements and including different HTML depending on the global variables. This is more similar to exceptions from a rule than to the rule itself; therefore it is an example of a gap in the system. Btw, it is also possible to use some third-party modules if you need an ability to use several templates.

The conclusions I made for Drupal during last week are below.

The advantages of Drupal:

  • Ideologically well-balanced and well-organized architecture for any needs of information management.
  • Large community of developers and supporters
  • Flexibility
  • Expandability by third-party modules and themes (a large set of them).

The disadvantages of Drupal:

  • Different versions are poorly backwards and forwards compatible, especially concerning third-party modules and themes.
  • Chaotic information in the drupal.org. There are many broken links. Articles and tutorials not always include the version number they are talking about.
  • Lack of layout design management in the core implementation.
  • Poor user interface, tricky and not very intuitive menus.

Connecting to the Internet in a dorm? Ahhh!

Friday, October 7th, 2005

Yesterday my girlfriend and I arrived to Berlin. We don’t have our computer here yet, but it will be brought in two weeks. There is no doubt, we’ll need to connect to the net. And I must find out the ways to do this. What we must purchase and how much will it cost? It seems to me that this will be not an easy task. But life isn’t easy for a whole so there is no mean to worry about it.

We already know that there is an anologue connection to the telephone, so we could connect to the Internet through “Deutsches Telekom” using an analogue modem.

Also there are two students living here in the dorm beneath by one floor who offer to join a WLAN and the Net. What does W stands there for: wireless or wire? Is it possible to connect a PC to the wireless modem (laptops usually use these ones)?

Many questions are unclear to me now, however I will get the answers to them right this evening.