Server2Go is a portable WAMP stack (Windows-Apache-MySQL-PHP) that runs out of the box without any installation, and can even run on write protected media (like a CD). This means that you can use Server2Go to develop your Drupal site locally (or copy over a Drupal site you have already made) and then burn it to a CD. The CD version will be fully searchable and will run all Drupal's php magic!
You can also put the files on a USB pendrive, and carry your full blown Drupal server in your pocket!
How it Works
The clever part is that Server2Go copies all the databases to a temp folder once the CD is launched. This means your Drupal site will behave as if it is live so it can be searched, edited, etc. However, although you can also add content to the site when it is launched from the CD this will obviously not be recorded to the CD as the CD is read only! The next time you launch the CD you'll be back with your original burnt site.
On the other hand, you can configure it to run more "normally" (i.e. not mirroring the databases) on a USB pendrive.
This tutorial is quite long, but the result is worth it in the end.
- Download a Server2Go package. (NOTE: this tutorial has been confirmed to work with the mini package [Apache 2.0.61], and with the latest version [Apache 2.2.15].
- Unzip it where you want it - to a temporary development folder if you're planning to burn to a CD, or to a USB Stick / pendrive. The folder will be called 'server2go'. In this tutorial we will rename the folder 'Drupal_S2G' to make file addresses easier to write out.
- Check that Server2Go is working by double clicking the Server2Go.exe file. You should get the splash screen saying "congratulations...." opening up in Internet Explorer.
Configure Server2Go for Development
Change the following settings in the pms_config.ini file in (Drupal_S2G) the main folder (use a program like Notepad++ to change it):
- [line 21] StartLocal=1 (this is for using when you want to develop the website and have to write files. If you want to use server2go to run off a read-only CD at a later point, you will have to change it back to =0)
- [line 61] BrowserSize=MAXIMIZE (This only works for Internet Explorer.)
- [line 69] LocalMirror=0 (this is so that the things you do to build your site are saved rather than carried out in a temporary folder)
Make a note of these values: 'HostName=127.0.0.1' [line 33] and this 'MySQLPort=7188' [line 80], as we will need them later.
Create a Drupal-Friendly Environment
- Make the following changes in (Drupal_S2G > server > config_tpl > php.ini) to make sure Apache has the right settings to run Drupal, and can provide clean-urls:
- [line 201] max_execution_time = 60 (instead of 30)
- [line 202] memory_limit = 64M (or larger)
- [lines 488-493] Put a semi-colon in front of "extension=php_sqlite.dll" and "extension=php_pdo_sqlite.dll". This prevents SQLite from loading.
- [lines 488-493] Remove the semi-colon in front of these lines: "extension=php_mysql_libmysql.dll", "extension=php_mysqli_libmysql.dll", "extension=php_pdo_mysql.dll". This enables MySQL and makes it available to Drupal.
- Change the following setting in (Drupal_S2G > server > config_tpl > httpd.conf)
- [line 164] Remove the '#' so it reads LoadModule rewrite_module modules/mod_rewrite.so
Prepare Drupal's Files
- Download Drupal and unzip it into the htdocs folder. You can unzip it so that it sits in a folder inside the htdocs folder. This means you'll have a folder inside htdocs called 'drupal-7.14' or something similar.
NOTE: YOU CAN IMPORT A SITE YOU HAVE ALREADY DEVELOPED. SEARCH THE DRUPAL HANDBOOK FOR ADVICE ON IMPORTING A DRUPAL SITE TO A LOCAL INSTALLATION.
You can rename it to anything you want, but in this case we'll call it 'drupal' so all Drupal's files will sit in (Drupal_S2G > htdocs > drupal ).
- Do the things the Drupal set up will tell you to do which are:
- Create a folder called 'files' in the main drupal folder i.e.(Drupal_S2G > htdocs > drupal > files)
- Create a 'modules' folder and a 'themes' folder in the default folder, this is where you will place your add-on modules and themes i.e. (Drupal_S2G > htdocs > drupal > sites > all
> modules) and (Drupal_S2G > htdocs > drupal > sites > all > themes)
- Copy the default settings file and rename it settings i.e. copy (Drupal_S2G > htdocs > drupal > sites > default > default.settings.php) and paste it in the same folder,
re-naming it to settings.php
For Drupal 6.X
Create a Database for Drupal
- Start server2go.exe in the 'Drupal_S2G' folder. It should open up the Server2Go start-page in a new browser
- Go to the phpmyadmin link under 'Tools' on the right-hand side.
- Click on priveleges
- Click on 'Add user'
- Under username put 'drupal_db' (or whatever you want to call your user); set 'host' as 'localhost' and set your own password (write it down!)
- Under database for user, choose 'Create a Database of the same name and grant all privileges'
- Click on the picture of a house to go to the phpmyadmin home page. Then select 'databases' and click on 'drupal_db'.
- Click on the 'privileges' tab at the top of the page and check that 'drupal_db' is one of the users listed as having access to the database. All done!
NOTE: READ OTHER DRUPAL HANDBOOK INFORMATION ABOUT SECURITY AND CREATING DATABASES. THIS IS A QUICK METHOD AND NOT NECESSARILY VERY SECURE...
- Now we're going to set up Drupal. Go to http://127.0.0.1:4001/drupal/ (or
http://127.0.0.1:4001/whatever-you-called-the-folder-you-unzipped-drupal...) and you should see the Drupal set-up page.
- After you've selected which language you are installing Drupal in, you will be asked to fill in the database details. In our case the database name is 'drupal_db'; the database username is 'drupal_db'; and the password is whatever password you chose.
- Click on the 'Advanced options'. In 'Database host' put: 127.0.0.1 and in 'Database port' put 7188, the settings we noted earlier.
- Save and continue.
- Follow all the rest of the stuff as in the Drupal Handbook.
- As you're installing on a local site, you might get this message:
warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini
It's harmless. If it really worries you, try this: http://drupal.org/project/smtp
- To check everything works, add some test content to your site and then close the browser. Restart Server2Go.exe once the server has shut down. If your content is there, bingo! It works!
OPTIONAL: Bundle in Firefox Portable
You can skip this step if you can assume that anyone launching your site will be happy using Internet Explorer. However, you can include Portable Firefox as the browser. To do this:
- Download the latest version of Portable Firefox (tested working with Firefox 2 and 3).
- Install Portable Firefox in the 'Drupal_S2G' folder (click on 'Browse' to locate the folder on your computer).
- Launch Portable Firefox by clicking on FirefoxPortable.exe in (Drupal_S2G > FirefoxPortable). You can choose to disable session store. You can choose a blank page as the firefox home page in 'Options' and hide the Bookmarks Toolbar so you have a cleaner looking browser window when it launches. Close Portable Firefox. Opening and closing the application is important!
- Go to (Drupal_S2G > FirefoxPortable > App > firefox) and rename firefox.exe to ffp.exe IMPORTANT: Leave the FirefoxPortable.exe in (Drupal_S2G > FirefoxPortable) unchanged!
- Create a file FirefoxPortable.ini in (Drupal_S2G > FirefoxPortable). You can use a program like Notepad++ to do this.
- Paste the following in the file:
NOTE: THESE SETTINGS ARE FOR SITE DEVELOPMENT. THEY WILL NEED TO BE CHANGED WHEN BURNING THE SITE TO CD (see instructions below).
- Open the pms_config.ini in (Drupal_S2G) and change the following:
[line 52] BrowserType=PORTABLEFIREFOX
[line 56] BrowserPath=FirefoxPortable/FirefoxPortable.EXE
- Check it works by launching the Server2Go.exe
Moving from Development to a CD
If you want to run some tests without wasting loads of CDs you can create an ISO of your files (you should be burning all the files INSIDE 'Drupal_S2G' and not just copying the 'Drupal_S2G' folder itself onto CD, otherwise the autorun will not work) by using software such as PowerISO (the free version will create ISOs up to 300MB in size, which should be enough for testing).
There are lots of nice settings to change, including the splash screen (Drupal_S2G > splash.png) which you could replace with any graphic you like and you can even change the name of the server i.e. replace 'Server2Go' with 'My Drupal Site on CD'. See the Server2Go website for more info. The following settings MUST be changed to make your site work on CD:
- In the pms_config.ini file in the (Drupal_S2G) folder:
- [line 21] StartLocal=0
- [line 39] DefaultFile=drupal/ (or whatever the folder is called where you have your drupal files. Don't forget the trailing slash)
- [line 69] LocalMirror=1
- In the pms_config.ini file in the (Drupal_S2G) folder.
- [line 14] KeepRunningAfterBrowserClose=1
- [line 17] ShowTrayIcon=1 (you need this to be able to shut down the server once you've finished with the CD).
- In the FirefoxPortable.ini in (Drupal_S2G > FirefoxPortable ):
If you are using Firefox portable, you will also have to change the following. Annoyingly, you can't be running firefox already when you start the CD and closing the browser will not shut down the server, this has to be done from the tray icon instead.
Comments welcome on this as the method has only been tested briefly.