Monday, February 21, 2011

HOWTO : Drupal 6.2 or 7 with Hiawatha 7.4 WebServer on Ubuntu Server/Desktop 10.10

I am going to setup a development environment of Drupal 6.2 or 7 with Hiawatha 7.4 on Ubuntu Desktop 10.10. However, this setting is also suit for production environment on Ubuntu Server 10.10 with a little bit changing.

Step 0 - Installation of Hiawatha

Follow this link to install required packages. You can omit the optional security settings at the moment.

Step 1 - Configuration of Hiawatha

Change the following section to the /etc/hiawatha/hiawatha.conf.

Binding {
   Port = 80
   #Interface = 127.0.0.1
   MaxKeepAlive = 30
   TimeForRequest = 3,20
   MaxRequestSize = 8192
   MaxUploadSize = 30
}


Add the following section to the /etc/hiawatha/hiawatha.conf.

UrlToolkit {
   ToolkitID = drupal7
   RequestURI exists Return
   Match /favicon.ico Return
   Match .* Rewrite /index.php
}


or/and

UrlToolkit {
   ToolkitID = drupal6
   RequestURI exists Return
   Match ^/favicon.ico$ Return
   Match /(.*)\?(.*) Rewrite /index.php?q=$1&$2
   Match /(.*) Rewrite /index.php?q=$1
}


Step 2 - Configuration of virtual host

sudo nano /etc/hiawatha/enable-site/drupal7

Drupal 7 :

VirtualHost {
   Hostname = localhost, 127.0.0.1
   WebsiteRoot = /var/www/drupal7
   StartFile = index.php
   SecureURL = false
   AccessLogfile = /var/log/hiawatha/access.log
   ErrorLogfile = /var/log/hiawatha/error.log
   TimeForCGI = 120
   #UseFastCGI = PHP5
   UseToolkit = drupal7
   #DenyBody = ^.*%3Cscript.*%3C%2Fscript%3E.*$
   ExecuteCGI = yes
   PreventCSRF = yes
   PreventSQLi = yes
   PreventXSS = yes
   TriggerOnCGIstatus = no
}


or

sudo nano /etc/hiawatha/enable-site/drupal6

Drupal 6 :

VirtualHost {
   Hostname = localhost, 127.0.0.1
   WebsiteRoot = /var/www/drupal6
   StartFile = index.php
   SecureURL = false
   AccessLogfile = /var/log/hiawatha/access.log
   ErrorLogfile = /var/log/hiawatha/error.log
   TimeForCGI = 120
   #UseFastCGI = PHP5
   UseToolkit = drupal6
   #DenyBody = ^.*%3Cscript.*%3C%2Fscript%3E.*$
   ExecuteCGI = yes
   PreventCSRF = yes
   PreventSQLi = yes
   PreventXSS = yes
   TriggerOnCGIstatus = no
}


Step 2a :

sudo /etc/init.d/hiawatha restart

Step 3 : Preparation of installation of Drupal

Download the Drupal from her official site. Extract the downloaded file and copy to /var/www/.

sudo tar -xzvf drupal-6.20.tar.gz

or

sudo tar -xzvf drupal-7.0.tar.gz

Step 3a :

Create a directory under /var/www/.

sudo mkdir /var/www/drupal6

or

sudo mkdir /var/www/drupal7

Step 3b :

Copy the files to the /var/www/.

sudo cp ~/drupal-6.20/* /var/www/drupal6

or

sudo cp ~/drupal-7.0/* /var/www/drupal7

Step 3c :

cd /var/www/drupal6

or

cd /var/www/drupal7

Step 3d :

sudo chmod a+w sites/default
sudo mkdir sites/default/files
sudo chmod a+w sites/default/files


sudo cp sites/default/default.settings.php sites/default/settings.php
sudo chmod a+w sites/default/settings.php


Step 3e :

mysql -u root -p

After entered the password, create a database for the installation.

create database drupal;

After that, then quit MySQL.

quit

Step 3f :

Open the browser and type "localhost" at the address field to continue the installation. The database name is "drupal".

When the installation is completed, carry out the following commands.

sudo chmod go-w sites/default
sudo chmod go-w sites/default/settings.php


sudo chmod a-r CHANGELOG.txt

Step 4 : Complete the installation

Drupal 6.2

sudo crontab -e

Add the following :

0 * * * * wget -O - -q -t 1 http://localhost/cron.php

or

Drupal 7

Administration -- Configuration -- System -- Cron

Get the Cron key at Administration -- Reports -- Status report -- Cron maintenance tasks.

sudo crontab -e

0 * * * * wget -O - -q -t 1 http://localhost/cron.php?cron_key=YOURKEY

Step 5 : Localization (Optional)

Download the required localization .po file at the following links.

http://localize.drupal.org/download
http://drupal.org/localize

That's all! See you.