Lab 8

Web Servers

 

 

Introduction

 

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.

 

Instructions:

 

1.      NOTE 1: this lab presumes you are familiar with the basics of WAMP. Ask for help where needed.

2.      NOTE 2: when finished you will DEMO your lab to the instructor.  If this doesn’t happen during the same lab period, make sure you save all your web and configuration files to your W drive so that you can easily get this working again later.

3.      Important: Go to c:/Wamp/Apache2/conf/.  Make a backup copy of httpd.conf (call it httpd.conf.orig)

4.      Turn the WAMP server on.

  1. Copy your Lab07 to a new Lab08 directory (inside the WAMP www directory). Your main file should still be called index.html
  2. 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”)

8.      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, about 14 lines 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?

9.      Verify that your old website is now be fully functional, via http://localhost

10.  Here is what you what you want to have when you are finished. 

    1. Create a re-direct so that one of your Perl files that took an argument in the URL now instead has a nice URL.  e.g. if you had:
      query.pl?zip=21401
      Make a redirect so that
      weather/21401/
      will re-direct to the first URL. Modify your JS program to use the new URL. You should not change the actual name of your Perl file.
    2. Create a URL re-write so that your main page Lab08/index.html is (silently) accessible via some different, nice URL.
    3. 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).  Instead, start by locating the “htpasswd” program on the C: drive, which you will need.
    4. As always, your code must be commented!

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

12.  Ensure all your pages validate and that you have met all requirements.

13.  DEMO your lab to the instructor.  If this is not done today, you can demo during the next lab period.

14.  Important: before you logout

    1. Save a copy of your web files to your W drive (as a backup)
    2. Save a copy of your httpd.conf file to your W drive
    3. Restore the original http.conf file from the httpd.conf.orig file that you created. Otherwise, the next student trying to use Wamp on that machine may have difficulty.

     

Deliverables

1)      All of your files for Lab08 should be in a folder called "Lab08" (without the quotes) on the Web drive.

2)      All files must be complete before you submit the hardcopy of your assignment. Do NOT modify your files after you have submitted your assignment.

3)      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)      The first page of the output of the W3C validator, as run on the final version of your Lab08/index.html (you’ll need the file upload feature to get this to work).  This should show that your document correctly validated, but turn it in anyway if you can’t get your page to validate. 

c)      A printout of just the modified parts of your Lab08/index.html file (there should be some, but not too many).  You can print more than the minimal parts out if necessary, but highlight/circle the parts you changed.

d)      Printout of your .htaccess file

e)      Printout of your password file

f)        Printouts of anything else you needed to create / modify to get this to work.

 

 

 

http://www.wampserver.com/phorum/read.php?f=2&i=5589&t=5589

In your httpd.conf file, find this line:
<Directory "C:/wamp/www">

Now, about 14 lines below that line, you will see this:
Options Indexes FollowSymLinks

Change that line to:
Options Indexes FollowSymLinks Includes ExecCGI

 

 

need to set shebang thing to

#!c:/Perl/bin/perl.exe

 

In config file,

change this:

AddHandler cgi-script .cgi

AddHandler cgi-script .pl