A huge variety of web services and providers are available, ranging from free online site builders to fully configurable virtual servers hosted by an ISP. For a large number of these, you'll be able to log in and create your website fairly easily, so why would you need web server software?
For a web developer, the advantage of having a server on your own PC is that you can test pages and sites before they go live. In particular, if you're working with complex scripts or plug-ins, there's always a danger that they may cause your site to stop working or create vulnerabilities.
Server2Go, which we demonstrate in the following walkthrough, can be installed on a USB drive. This means you can take your files with you wherever you go, and use them even on a PC where you have no administrator privileges and are unable to install any programs. This will be useful if you want to demonstrate a test site to someone else or simply try something out.
It's also possible to create media-rich applications that can be distributed to run from disc when you don't want them available online. If you also bundle the installation-free version of Firefox, you'll gain complete control over the presentation and distribution of your files.
Getting up and running with Server2Go
Server2Go runs without needing to install itself on your machine, which means you can launch it directly from write-protected media. Because it usually includes a fully functioning database, you can create complex applications such as catalogues and computer-based training (CBT) products that can be sent out on disc.
The program comes in a number of versions, including a micro package that consists of the web server Apache. In most cases, however, you'll want to use a version that includes PHP, MySQL and Perl to ensure you have everything you need for a fully functioning site.
Apache is the core application. The popular open-source web server could be downloaded as part of Server2Go in three different releases at the time of writing: 1.3.55, 2.0.63 and 2.2.11. The first two versions are stable but older forms, while the latter is a more recent release.
Database functions are handled by the open-source MySQL program, with which many web developers will be familiar, along with the less commonly encountered SQLite. This allows databases to be run without installation or administration. Finally, Perl and PHP are popular coding languages required to run a large number of interactive sites. PHP is particularly useful alongside MySQL for handling databases, with Server2Go supporting PHP 5.2 and MySQL 5.0.41.
It's possible to tinker around with various settings within configuration files after you've downloaded Server2Go. We'll do a little of that here in order to ensure that the program runs alongside another portable app, FirefoxPortable.
In general, however, one of the best features of the package is that it runs effectively and efficiently with no further requirements on your part.
STEP 1. Download the Server2Go software from server2go-web.de. Click Downloads and select a version. We recommend the most complete package, but you can opt for a download of between 6MB and 45MB.
STEP 2. Server2Go downloads as a self-extracting .zip file. Double-click this. Once its contents have been extracted into a new folder, have a nose around and familiarise yourself with the various folders.
You'll find an icon that launches the program and six folders. Server contains the applications that will run your web pages, dbdir handles databases and cgi-bin stores executable scripts. See Using phpMyAdmin (below) to learn about the Admin folder. Htdocs is the most important folder: this is where you'll store the web pages you create.
STEP 3. To begin using Server2Go immediately, double-click the main icon to launch the web server. This will open your web browser with the address http://127.0.0.1:4001 - a test page that confirms you've unzipped the package correctly. To open any other files in your htdocs folder, type the name of the file after the localhost address. Closing the browser will shut down the server.
STEP 4. In the next few steps, we'll show you how to create a truly self-contained system using the portable version of Firefox available from tinyurl.com/mam23. Having downloaded a copy, double-click the .zip file to extract its contents into the folder that contains your server software. There, you'll find a folder called FirefoxPortable; double-clicking the icon within this folder will launch the application.
STEP 5. You'll need to make a few configuration changes if you want to use Firefox as the default browser. First, go to the folder FirefoxPortable\App\Firefox and change the name of the icon Firefox.exe to ffp.exe. Don't change the name of the icon FirefoxPortable in the top directory. Instead, create a file called FirefoxPortable.ini and add the following code in the directory FirefoxPortable\:
STEP 6. Finally, in the Server2Go folder, open the file pms_config.ini and find the line that begins BrowserType. Change this from BrowserType=IEXPLORER to BrowserType=PORTABLEFIREFOX, and the line BrowserPath=ExternalBrowser/SimpleBrowser.exe to BrowserPath=FirefoxPortable/FirefoxPortable.EXE (this assumes that you unzipped FirefoxPortable into the server that hosts the rest of your Server2Go files).
Firefox will now launch as the default browser, allowing you to design pages without worrying about what software is installed on the end-user's PC.
Setting up and managing SQL databases is a complex task when completed via the command line, so the close integration of MySQL and PHP in phpMyAdmin comes in incredibly useful.
This is bundled as a standard part of the Server2Go package. You can access it from your web browser by typing phpMyAdmin after the address of your local server (127.0.0.1:4001). From here, you'll see the splash screen with some basic information about the version of MySQL being run on your machine, as well as a drop-down menu of databases in the left-hand panel.
Selecting one of these databases will display it in the main window, where you'll see a list of tables contained within. Tabs let you sort information, export or import records, create new tables via operations or edit privileges to restrict access.
To create a new database in phpMyAdmin, locate the field entitled 'Create new database' that sits about halfway down the home page. Enter the name of your database and click Create.
Next, you'll be asked to create a table with a number of fields. You can then specify the name, type and any default values contained in those fields.
Running fully fledged apps with Server2Go
Once Server2Go is up and running, it's time for you to create something interesting that can be distributed as a self-contained set of files.
An obvious option is to design a website using your favourite editor. Pages saved to the htdocs folder wherever you've installed Server2Go will then be displayed in the browser.
However, creating simple HTML pages doesn't really require this kind of application. After all, creating HTML documents with links will simply display in the browser when you double-click them, with the ability to click through to other files.
Since Server2Go provides you with fully working versions of MySQL and PHP (depending on which version you've downloaded), you can create far more complex applications. In this section, we'll look at bundling a search engine, Zoom Search, as well as installing a content management system, Joomla.
STEP 1. Zoom Search Engine 6.0 can be used to add search facilities to a website or folder. Download it from wrensoft.com and install it to your hard drive. The free version can be used on sites consisting of up to 50 pages, while a $49 (£30) Standard licence allows you to search up to 100 pages. Professional and Enterprise versions can search up to 200,000 or an unlimited number of files respectively. Launch the wizard to create a simple search index of your site.
STEP 2. Allow Zoom Search to scan through the pages of the indicated site and create a set of index files for copying into your final project. You'll need to specify a start directory (the folder to be searched) and an output directory (where the index will be stored). Keeping to a single search will allow you to avoid most of the other, more complex options.
STEP 3. Zoom Search also creates a default search.html page. Ensure that this, its CSS files and the index that Zoom will use to search your site are in your Server2Go folders so that you can copy them all across with your final project.
STEP 4. To create a dynamic interactive site with Joomla, download the latest version from joomla.org/download.html. Unzip this file into a folder called joomla in your htdocs directory. Launch Server2Go and then navigate to the joomla folder, typically http://127.0.0.1:4001/joomla. This will start the Joomla installer. Select the language you want and click Next.
STEP 5. Joomla first launches a preinstallation check to ensure your system is compatible. Once it's satisfied (it should be with a default install of Server2Go), click Next to view the licence, then click Next again to proceed to the first stage of installation. This configures the SQL database required by Joomla. For simplicity - and to test an installation - you can enter the username as root and leave the password blank. This is insecure, of course; to change it you'll need to use phpMyAdmin to set a default use name and password. Note that the host name should be localhost.
STEP 6. FTP settings can be ignored at this stage, but for the next name you must enter a password to use with the username admin to access Joomla's administrative features. It's also a good idea to enter a name for your website and email address.
STEP 7. As a final security step, navigate to the folder where you installed Joomla and delete the directory installation: Joomla won't load in the browser until you do so.
Typing the address 127.0.0.1:4001/joomla will load the program in your browser, while 127.0.0.1:4001/joomla/administrator lets you configure the application. Go to Extensions, Template Manager to modify the appearance of your site, and Content, Article Manager to begin adding content. You'll find plenty of Joomla templates by searching online, and anything you add to your site is completely searchable because the material is stored in a MySQL database.
STEP 8. The original function of Server2Go was to create a fully working website that could run from disc. Once you've added content to your site, the next step is to create a version that can be distributed in this way. If you're distributing a single site, you'll want to edit the pms_config.ini file so that the site opens automatically when Server2Go is launched, which means looking for the line DefaultFile and adding the folder name for your site (for example, joomla).
Once this is done, simply open your favourite disc-copying software and create a job that will move all the files you need to disc. Make sure you copy everything in the Server2Go folder, including third-party programs such as Zoomsearch. After the disc has been created, it'll run your website as a self-contained application.
Server2Go and FirefoxPortable are two of a number of products designed to run without installation, meaning they can be carried on to any PC via a USB drive or CD. At portableapps.com, you'll find a complete suite of such applications, including OpenOffice.org for your productivity needs, the Sumatra PDF reader, Pidgin Portable to handle instant messaging clients, and antivirus software from ClamWin.
With the suite installed on your USB drive (the standard suite consumes 355MB of disk space), you can be sure that even in internet cafes or security-conscious work environments you'll have most of the basic tools you need to carry out your required tasks.