Lab 8

Web Servers





This week we learned how you can control the web server to rewrite/redirect URLs (to provide more useful and stable URLs) and how to do basic access control.  In this lab you will apply all of those concepts.




1.      This lab involves using WAMP – a nicely packaged combo of Apache, MySQL, and PHP for Windows. However, you need to have administrative privileges to run WAMP on your PC – which you probably have in Bancroft but not in the lab.  To address this, we will run WAMP inside a “virtual machine” that will simulate a Windows XP machine where you are an administrator.  We will use VMWare to accomplish this.

2.      Starting up VMWare:

    1. Click on the VMWare icon
    2. Open the file in c:\VM Images\Windows XP\Windows XP Professional.vmx.  You do not want to “power on” this machine.
    3. Right Click on the Windows XP Professional Tab (on the words)
    4. Go to Snapshot manager.  Click on “Initial Configuration with Perl”, then hit the Go to button.
    5. Make sure you picked the one with Perl!
    6. There are a few warning messages...just say yes to all.  If it asks if you moved or copied the image, click the "I copied it" button
    7. Loading is very slow – read the rest of the lab while you wait.
    8. Once loaded, X out of the small window on the left so you can see the full width of the screen. Maximize the VMWare window.
    9. Note that you will now see two taskbars and Start buttons – one for your actual PC and one for the virtual machine.
    10. To copy a file from the virtual image to the host (or vice versa)...just drag and drop
    11. Now you are ready to do the lab below.
    12. Important: when finished for the day you must save a new “snapshot” of the virtual machine – or all your work will be lost!  Save the snapshot as something like “MIDN Smith Day 1” . After saving your snapshot, you can close VMWare. Just select “power off” when prompted.

3.      When finished you will DEMO pieces of your lab to the instructor. 

4.      The instructions below all refer to things you do inside the virtual machine.

5.      Important: Go to C:\wamp\bin\apache\apache2.2.8\conf.  Make a backup copy of httpd.conf (call it httpd.conf.orig)

6.      Load http://localhost in your browser to verify that WAMP is on.  If not, turn it on.

  1. If your Lab07 is not functional (including the Perl parts), talk to the instructor about what to use for the next step.
  2. Copy your Lab07 (from your W: drive) to C:\wamp\www\Lab07 on the virtual machine, then rename it to Lab08. Your main file should still be called index.html. Verify that you can access your main file at http://localhost/Lab08/index.html
  3. Turn on the “rewrite_module” (click on WAMP icon, then pick “Apache modules”)

10.  Modify WAMP settings to get your old functionality working on the WAMP server. If you used relative URLs, then all you need is to enable Perl functionality:

    1. In your httpd.conf file, find this line:
      <Directory "C:/wamp/www">
      Now, below that line, you will see this:
      Options Indexes FollowSymLinks
      Change that line to:
      Options Indexes FollowSymLinks Includes ExecCGI
    2. In your httpd.conf file, find this line:
      AddHandler cgi-script .cgi
      Uncomment it, then modify so you have these two lines:
      AddHandler cgi-script .cgi
      AddHandler cgi-script .pl
    3. Edit all your Perl files so that the very first line is: #!c:/Perl/bin/perl.exe
    4. If you change httpd.conf, do you need to restart the server?

11.  Verify that your old website is now fully functional, via http://localhost, including the Perl aspects.

12.  Demo #1: Show the instructor that your old website is working inside the virtual machine.

13.  Tip: Windows will may not directly allow you to create a “.htaccess” file. You can, however, make a file with Crimson Editor and then save it with this name. Be sure to choose “All files” (not “Text files”) from the file types in the Save dialog window.

14.  Now you will use the web server to make changes. Here is what you what you want to have when you are finished:

    1. As always, your code must be commented! In this case, you are adding comments to the .htaccess file.
    2. Create a re-direct so that one of your Perl files that took an argument in the URL now instead has a nice URL.  For example, you want the user to be able to type in a “nice” URL like:
      and be redirected by the web server to something like
      Use an actual Perl file that is used by your website. You should not change the actual name of your Perl file.
    3. Modify your JS code to make use of the re-direct that you just made, e.g. it no longer directly calls but invokes the same program using the “nice” URL instead.
    4. Create a URL re-write so that your main page Lab08/index.html is (silently) accessible via some different, nice URL. For instance, typing in  http://localhost/Lab08/swim into a browser might transparently fetch the index.html file (the browser still thinks it fetched Lab08/swim).
    5. Add “Basic” password protection to your index.html file, via .htaccess. Make at least two users with valid access – one should be “test” with password “test”. Don’t try to enter passwords manually (even with a web script that claims to encrypt them for you – this doesn’t work!).  Instead, start by locating the “htpasswd” program inside C:/wamp, which you will need.

15.  Ensure your page works with Firefox. Having it work on IE is encouraged but not required.

16.  Demo #2: Show the instructor that the above requirements are working.

17.  For future reference (and turn-in requirements), copy your .htaccess file and the .htpasswd file to your W: drive.

18.  Important: before you close VMWare, save a snapshot!  See instructions above.


1)      Turn in the following hardcopy on or before the due date, stapled together in the following order (coversheet on top):

a)      A completed assignment coversheet.  Your comments will help us improve the course.

b)      Printout of your .htaccess file

c)      Printout of your password file