Running multiple versions of Drupal on Windows
Once you've been developing Drupal modules for any length of time you find that you need to test code on multiple versions of Drupal. The easiest way to do this is have separate Drupal releases running as virtual hosts. In this guide I'll walk though setting up Apache virtual hosts for Drupal 5 and Drupal HEAD. I'm assuming you're running Windows 2000 or greater and that you've already gotten Apache, MySQL and PHP setup and running on your local machine.
Configure your hosts file
The first step is to add lines to your hosts file so you can refer to the different Drupal sites with URLs like http://drupal5/ and http://drupalhead/. As the Wikipedia explains, the location of the file may vary:
Windows NT/2000/XP/Vista:
%SystemRoot%\system32\drivers\etc\is the default location, which may be changed. The actual directory is determined by the Registry key\HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath.
On my machine the path was c:\windows\system32\drivers\etc\hosts. When you open the file you'll see something like:
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhostAt the bottom append the following two lines:
127.0.0.1 drupal5
127.0.0.1 drupalheadDownload Drupal
The next step is to download the versions of Drupal you'd like to run. I highly recommend using CVS to do this. Drupal.org has some excellent instructions for using Tortoise CVS to checkout a Drupal release. You'll need to repeat this process twice, first for the DRUPAL-5 branch which will go into c:\drupal\drupal5 (you can enter this path on the Options tab of the CVS checkout dialog) and again for HEAD which will go into c:\drupal\drupalhead.
If you refuse to figure out CVS, just download the releases and unpack them into the directories mentioned above. Later on, after you've gotten frustrated updating by hand you can figure out how to check them out from CVS.
You should now have a c:\drupal directory with two sub-directories named drupal5 and drupalhead, each of which contain—among other things—an index.php file.
Create the databases
You need to create a database for both Drupal installations. The best practice would be creating a user account for your web server to use to connect to the database. If you want to see how that's done, refer back to my MySQL setup instructions. For simplicity, we'll just connect as root.
Open up a command prompt and use the mysql client to connect and create the databases:
C:\Documents and Settings\amorton>mysql -u root -p
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 185 to server version: 5.0.22-community-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database drupal5;
Query OK, 1 row affected (0.14 sec)
mysql> create database drupalhead;
Query OK, 1 row affected (0.03 sec)
mysql> exit
ByeConfigure Apache
Begin by stopping your Apache server. You can do this using the Apache Monitor program, the shortcut in the Start menu, or using the Services administrative tool.
Locate and open Apache's httpd.conf file. There's probably a shortcut in the Start menu to do this at Start Menu > Programs > Apache HTTP Server > Configure Apache Server > Edit the Apache httpd.conf Configuration File. It's a big file with lots of settings. I'd recommend making a backup at this point, that way if you screw something up you've got a place to fall back to.
Search the file for the following line:
LoadModule rewrite_module modules/mod_rewrite.soIf it has been commented by placing a pound sign at the beginning of the line, remove the pound sign.
Now, scroll to the bottom of the file and append the following block of text:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
# Protect files and directories from prying eyes.
<FilesMatch "(\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
Order allow,deny
</FilesMatch>
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Follow symbolic links in this directory.
Options +FollowSymLinks
# Customized error messages.
ErrorDocument 404 /index.php
# Set the default handler.
DirectoryIndex index.php
# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.
# PHP 4, Apache 1.
<IfModule mod_php4.c>
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0
</IfModule>
# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0
</IfModule>
# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0
</IfModule>
# DRUPAL 5 VIRTUAL HOST
<VirtualHost *:80>
ServerName drupal5
DocumentRoot "c:/drupal/drupal5"
<Directory "c:/drupal/drupal5">
AllowOverride None
Order allow,deny
Allow from all
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
</Directory>
</VirtualHost>
# DRUPAL HEAD VIRTUAL HOST
<VirtualHost *:80>
ServerName drupalhead
DocumentRoot "c:/drupal/drupalhead"
<Directory "c:/drupal/drupalhead">
AllowOverride None
Order allow,deny
Allow from all
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
# Rewrite URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
</Directory>
</VirtualHost>Most of this consists of configuration directives pulled from Drupal's .htaccess files. They need to be in the site's configuration file because on Windows .htaccess files are not read by default and I've never figured out how to get it working reliably.
Restart Apache and check for errors. If it won't start there is probably something wrong with your httpd.conf file.
Install Drupal
At this point, you should be able to point your browser to http://drupal5 and http://drupalhead and see installation pages for Drupal 5 and HEAD. Finish up the installation and you'll be able to test code for both versions of Drupal.







