This post describes my recent experience with creating a test environment for the
Drupal content management platform using BundleWorks. It involved some upfront work to package Drupal, but now I can very easily create independent Drupal environments for development and testing.
Creating the Bundles
For my Drupal environment, I needed bundles for Apache, PHP, MySQL and for Drupal itself. For Apache and MySQL, I already had BundleWorks bundles, which were created with the
bw bundle. For PHP, I had a bundle already created, but I needed to rebuild PHP to support the gd and mbstrings modules. So I used the loadable-source bundler to create my PHP bundle as follows:
bw bundle loadable-source /opt/bundles none
Enter directory containing source: php-5.2.5
Enter bundle name [php]: php
Enter bundle version [5.2.5]: 5.2.5
Enter any arguments for configure: --with-mysql=/opt/bundles/mysqlserver/5.0.45/linux-ppc
--enable-cli --enable-fastcgi --enable-force-cgi-redirect
--with-zlib --with-gd --enable-mbstring
For the Drupal bundle, I created a custom bundle with two scripts inside the "actions" directory: install.sh and cron.sh.
The install script sets up the Drupal 'work' directory as follows:
1. Creates 'files' and 'tmp' directories for Drupal to keep each Drupal installation separate.
2. Copies an Apache conf file into a 'config' directory to be included inside Apache's main httpd.conf. This conf file contains all the directives needed for Drupal, including directives for mod_fcgi used to run PHP with FastCGI.
3. Copies the Drupal distribution into a 'root' directory which is referenced in the conf file using the Apache Alias and Directory commands.
4. Creates an 'actions' directory with a load script that sets DRUPAL_HOST and DRUPAL_PORT used when running the Drupal cron job.
The cron.sh simply calls the Drupal cron URL as follows:
#!/bin/sh
wget -O - -q -t 1 [url]http://$DRUPAL_HOST:$DRUPAL_PORT/cron.php[/url] \
>$WORK_DIR/drupal_cron.out 2>$WORK_DIR/drupal_cron.err
This cron.sh script is then called periodically from an entry in the cron table as follows:
30 * * * * /srv/bundleworks/work/bin/bw /srv/env/cms/drupal cron
Deploying the Bundles
After adding these bundles to /opt/bundles, I used the following BundleWorks commands to create an environment and deploy all the bundles.
bw envcreate /srv/env/cms
bw deploy /opt/bundles/mysqlserver/5.0.45 /srv/env/cms
bw deploy /opt/bundles/apache/2.2.6 /srv/env/cms
bw deploy /opt/bundles/php/5.2.5 /srv/env/cms
bw deploy /opt/bundles/drupal/5.5 /srv/env/cms
In the case of the mysqlserver and apache deployments, I was prompted to enter port numbers. By choosing unique port numbers, I can run multiple independent instances of these applications, each with their own 'work' directory.
Running the Environment
Once the bundles were deployed, running Apache and MySQL was a snap:
use cms
mysqlserver start
apache start
Drupal Setup
Setting up Drupal was straightforward at this point. I first created a Drupal table in the MySQL instance by running the 'mysql' client at the command line. I then used Drupal's setup wizard and administrative interface to configure Drupal (including setting the 'tmp' and 'files' to point into the environment). Finally I wired up the cron.sh script as shown above.
I then had a completely independent instance of Drupal running on my server, as well as a way to create other Drupal environments very easily.
Edited 1 time(s). Last edit at 12/08/2007 07:58AM by rsauers.