Blog: Drupal On A Stick
Getting Drupal to Run on a USB Stick
One Solution and Why It Didn’t Work for Us
One Solution and Why It Didn’t Work for Us
For the past month I’ve been working with Development Seed to get a fully functional Drupal website up and running on a usb drive for a project we’re working on with the American Institute of Architects’ Communities by Design initiative. And after a couple of setbacks, it works and it’s fast.
Jeff wrote about how we ended up getting the Drupal site – actually a community editable disaster relief kit – running on the stick. I wanted to follow that up with a run down of our first plan of action, which seemed like the perfect solution but in the end just didn’t work. Hopefully this explanation will save other developers some time.
To get Drupal running on a stick we had two main challenges - getting everything we needed to run Drupal (a web server, PHP, and MySql) up on a usb stick and making it work on multiple operating systems.
After a bit of research, we came up with the following options:
WSOP
Pros:
- Already has everything on a stick, which would solve our problem of how to get everything on a stick
Cons:
- Only works on Windows
- Somewhat buggy and not well tested
- Still would need a solution that runs on operating systems other than Windows
Google Analytics on a USB Stick with Drupal
How To Get Detailed Metrics for Drupal Site Running on USB Drives
How To Get Detailed Metrics for Drupal Site Running on USB Drives
We recently put a disaster relief kit in the form of a Drupal website on a usb drive for the American Institute of Architects’ Communities by Design initiative (for details, see here, here, and here). As development proceeded, we got to discussing setting up the Drupal installation to “phone home” to get software updates and centralized backups. And if the installations were already phoning home, well, why not track how and where they are being used?
Using Google Analytics, we developed a tracking mechanism for each and every copy of Drupal on a stick. In this post I’ll describe how we did it.
We decided we wanted to track the stick’s usage – the application pages they visited and length of stay – whenever users were connected to the internet. Google Analytics fit the bill as the best means of tracking, but how would users call Google's javascripts? Google doesn't allow listing 127.0.0.1 or localhost as a domain for purposes of their tracking tools. We solved this problem by embedding an IFrame element in page.tpl.php of the application’s custom theme and listed its source a newly purchased domain. We'll use http://example.com for the purposes of this post so as to keep our tracking domain untainted with spider traffic.
Database Backups for Drupal on a Stick
How We Got Back Ups and Restores Working in an On a Stick Environment
How We Got Back Ups and Restores Working in an On a Stick Environment
As we talked about here and here, we recently built a dynamic disaster relief kit in the form of a Drupal website on a usb thumb drive for the American Institute of Architects’ Communities by Design initiative. Users are able to add and edit content in the kit, so we wanted to make it possible for users to create a backup of the Drupal on a Stick database and, when necessary, restore the database from one of the available backups.
Here's how it looks:
This sounds simple enough, and in fact there are some useful options out there for running backups when operating a Drupal installation in normal environments (e.g. LAMP on a hosted server). However, the constraints of running in an "on a stick" environment meant we needed a custom solution. Why? To begin with large numbers of writes and reads from the flash drive take quite a long time. Also, we wanted to avoid the classic situation of creating a snake that eats its own tail - we didn't want to attempt to fully restore a Drupal database from within Drupal itself.
Getting a Web Server to Run on a USB Drive
Focusing on Functionality and Compatibility
Focusing on Functionality and Compatibility
Recently we put a disaster preparedness kit that acted as a Drupal website on a usb thumb drive for the American Institute of Architects’ Communities by Design Initiative. This meant getting the entire Apache+php+MySQL stack running from the usb drive and essentially acting as a web server on a stick. Installing a web server is almost never as simple of a task as you'd expect no matter how often you do it, especially when it needs to be set it up on the fly from any computer.
There are several platforms that thankfully provide fully contained web server environments that make this process much easier. Among us Mac developers MAMP is very popular, and on the Windows side platforms like XAMMP and the Uniform Server work well. For this project we started from XAMMP, and it got us fairly close right out of the box. However, there were some drawbacks – it was big, and it assumed some things we didn't like. So we made some performance tweaks, most importantly enabling and configuring a php cache, to speed things up. We also created some additional nice features like custom start up scripts and icons. With this, the server was set up for Windows users.
Here is a screencast showing how it runs off the stick. I’ll explain how we did it here to hopefully save other developers some time below.


