Demonstrating a web-based application online, such as a Moodle installation, blog software, or other online applications, either in the classroom or as part of a presentation, can be fraught with all sorts of potential hurdles. Assuming the classroom or presentation room you are in actually has a network connection, will it be fast and reliable enough for your purposes? Can you connect to the network and bypass firewalls or other security settings? Will your site be accessible when you need it? Do you have a backup plan in case all goes wrong?
Perhaps the easiest way to ensure your demonstration or presentation goes as planned is to take the online application offline. By configuring your computer to serve web pages, and by installing some easily-to-use applications, you can have full control over your web-based applications, and can focus on demonstrating exactly how they are supposed to work. An added benefit is that you can allow people to work with and test an application without needing to worry about the test data appearing on the “live” site.
Great for testing, too!
Even if you’re not planning on demonstrating an online application, it makes sense to run a test or a development version of web applications on your local machine. This allows you to keep a fully-functional backup and to easily try out modifications without compromising your live site, or without filling up your online database with unwanted test data. Tweak things to your liking on your development version and then apply the final, working changes to the online version for seamless application updates. Testing and developing directly on your local machine saves time and bandwidth, too.
Outlined below are the steps required to get a full LAMP (Linux, Apache, MySQL, PHP) based application installed and mirrored on either a Macintosh running OS X or a Windows machine.
Using OS X
While OS X comes with the Apache webserver and the PHP coding language pre-installed (turn it on in the system preferences under sharing -> web sharing), it involves a bit of technical tinkering to get anything but the most basic static HTML pages to display using the localhost server. With the upgrade to OS 10.5, it’s become even more confusing. My advice is to skip this set-up entirely and instead look at using an application like MAMP <www.mamp.info>. It’s advertised as a “one-click solution for setting up your personal webserver,” and that’s pretty much all you need to know. Setting this up couldn’t be simpler—you download a disk image and install from there. MAMP gets installed in your applications folder, and the installation includes the Apache server (2.0.59), PHP versions 4.4.7 & 5.2.5 (with Zend Optimizer & eAccelerator), MySQL (version 5.0.41) and SQL, as well as the phpMyAdmin and SQLiteManager database admin tools. Note that these are not the latest versions of the various packages, however you should have no problems running your web-based applications with this configuration.
It’s probably best to only run MAMP when you need it, so as to preserve CPU power. To start things, you can use either a dashboard widget that comes with the installation, or there’s a small application through which you can start and stop the Apache and MySQL server, as well as set the application preferences—the ports you will use to access Apache and MySQL, and the path to the document root directory (MAMP should automatically set these preferences for you). Because MAMP is a fully self-contained application, it’s very simple to upgrade (just download the newest version) or delete (move the entire MAMP folder to the trash).
Once you’ve got the application running, you can create a backup of the site you want to work with and move the entire online document root directory (public_html on most standard linux-based servers) into the MAMP document root directory (the htdocs folder). Then, if you’re using a database, save a copy to your computer from your server and set up your local database (using a tool like PhPMyAdmin), edit any configuration files to point to the database, and that’s it. You should now have a fully-functioning copy of your online application on your computer, accessible via your web browser. You can install things in the exact same way as you have them set on the online server, and all internal links should work—just remember to change configuration file directory paths, database names, and passwords to point to the localhost directory where needed. For example, I run a demo version of a student site on my laptop at <localhost:8888/school>—8888 represents the Apache port number set in MAMP’s preferences, and /school is the name of the folder I have all the site files stored in within the MAMP document root (Applications/MAMP/htdocs) directory. Not all the classrooms at my workplace have Internet access, so this has already proven invaluable for demonstrating the site to students, as well as for creating and testing the initial site.
Selecting and installing a WAMP package for Windows
The difference between LAMP, MAMP, and WAMP (Windows, Apache, MySQL, PHP) is the Windows element. While there are more WAMP install packages available for Windows than you would probably care to sort through, a useful comparison chart can be found at <en.wikipedia.org/wiki/Comparison_of_WAMPs>. Since several WAMP install packages are no longer being maintained, it is best to look at the release dates and version numbers to find a package that is both up-to-date and has gone though a few versions of debugging.
The WAMP package which I recommend and have been using over the years is WampServer, formerly WAMP5. The latest version of WampServer is 2.0c and was released on 5 May 2008. It includes Apache 2.2.8, MySQL 5.0.51b, and PHP 5.2.6. It also comes bundled with PhpMyAdmin and SQLitemanager, two useful tools for administering your databases. You can download the WampServer.exe file, a 20Mb executable file, from <wampserver.com/en/index.php> and double click on the .exe file to install it. I would advise installing it at the root level, for example ‘c:\wamp’. After the install is complete, you will notice a small icon in the Windows task bar. WampServer will also appear in your startup menu. Simply click on the Wamp icon in the task bar and select “Start all services” to start Apache webserver and the MySQL database server.
Starting and stopping services
You can start and stop both Apache and MySQL services from the icon in the task bar. Since you are most likely going to be using your local webserver for either testing or demonstrations, you probably don’t want the webserver running continuously in the background consuming valuable system resources. To check what services start up automatically on your Windows computer, go to the Windows control panel, open Administrative Tools, double-click on the services icon and scroll down the list to find the Apache and MySQL services. Double-click on the title of the service to verify that the Apache and MySQL services are set to start manually. While you have the services window open, you may want to check what other services are stealthily running in the background and set them to rest as well.
Backing up and moving data
Once Apache and MySQL are running (you can verify this by the small icon which looks like a meter in the task bar), fire up your favorite web browser and enter localhost or 127.0.0.1 as the web address. You should see WAMPServer’s start page. Now you can copy the web content which you would like to demonstrate from your online server to your local PC using FTP. On your local computer, save all web files to: ‘c:\wamp\www’ or if you are not sure where you installed WampServer, search for wamp. If you want to move an existing online application to your local server that includes a database, such as Moodle, you can use PhpMyAdmin to backup your online database as a SQL text file and restore it on your local computer. There is a useful guide at <docs.moodle.org/en/Backup_FAQ> which outlines how to back up and restore Moodle’s database, but this guide is also applicable to other types of online applications that require a database. You can install a fresh copy of the web application (such as Moodle or WordPress) on your computer and then if you need to copy any student content over from the database, use PhpMyAdmin to backup the original database as a SQL file and import it (again using PhpMyAdmin) on your Windows computer running the WAMP package.
In most cases you won’t have to worry about the configuration files for Apache, MySQL and PHP, but it is good to know where they exist and that they can easily be edited using a text editor. When installing applications such as Moodle, PHP warnings occasionally pop up. Typically, warnings about magic quotes, memory limits to process scripts, and file upload limits can be remedied by editing the php.ini file. From the task bar, select the same WAMP icon used to start and stop MySQL and Apache, and look under the config file menu to find the httpd.con f file for Apache, the php.ini file for the PHP processor, and the my.ini file for MySQL configuration.
Setting up a WAP
It is even possible to set up your computer as a WAP (Wireless Access Point) in the room that you are presenting in. This would allow participants who have a wireless network card in their computer to access your webserver which you installed the WAMP application on. On several occasions I have given Moodle workshops in a room with no computers or network. Participants brought along Wi-Fi enabled notebooks and connected to my notebook computer, set up as a WAP, to access Moodle running on my PC. More information on setting up your computer to serve as a WAP can be found here: <www.microsoft.com/windowsxp/using/networking/expert/bowman_02april08.mspx>.
While most web-based applications will run on a notebook computer, your notebook will probably not perform as well as a dedicated server will. Applications may be slower, particularly with large databases or if several people are accessing your computer. To speed things up, you can try increasing the amount of memory dedicated to running scripts. You can also upgrade the amount of memory on your computer as well as shut down applications and services running in the background that are not needed.