You will be building a web server using Ubuntu and Apache.
You will be learning to create a dynamic web application using CGI.
Part 1.
You will be creating your own personal web server for use during the course.
At least right now, the computers in the networking lab have no Internet connectivity.
Thus we will do things the old-fashioned way, building from the source code!
Pick a machine in the networking lab
Boot from an Ubuntu CD and install operating system
Choose whatever you like for server name, username and password
However you will need to tell me the details including password
Install Apache web server from source
Unpack and untar Apache
Follow instructions in the file INSTALL
Pass --enable-so to configure, this makes it easier to add PHP later
Install Apache in its default location, /use/local/apache2
Update the Apache configuration file
Configuration is via the httpd.conf file in conf subdirectory
ServerName needs to be changed to match your chosen server name
Test out the web server
Start/stop/restart using the script bin/apachectl
Open browser to localhost to test
Test making a change to the main web site page at htdocs/index.html
Familiarize yourself with logging
Log files live in logs/
Test out the CGI (Common Gateway Interface)
Figure out how to load the test-cgi script that lives in cgi-bin/
If something goes wrong, check the log files
You may have to adjust permissions to get things working
What username/group does Apache use when serving web pages? Use ps -Af to investigate
Part 2.
One way a web server can provide dynamic content is by shelling out to an external program or script via CGI.
You will be creating a simple web application that can store name/value pairs.
The pairs are associated with a particular filename.
You can store the pairs in the file in any way you like so long as it behaves as specified below.
You need to create two HTML pages get.html and set.html.
The get.html page works as follows:
Contains a form with two fields, the filename and the field name
On submission, the form calls your CGI program and returns the matching value
If no matching name is found, it returns a blank page
If something goes wrong (e.g. the filename doesn't exist on the web server),
print out "ERROR," followed by a description of the problem
Names are case sensitive and must match exactly
Name and values are no more than 255 ASCII characters in length
If a file contains multiple pairs with the same name, return the value of the last pair in the file
The set.html page works as follows:
Contains a form with three fields, the filename, the field name, and the field value
On submission, the form calls a CGI program that stores the pair at the end of the given filename
If no filename currently exists in cgi-bin/ with the given name, a new one is created
The new pair is added to the end of the file, this occurs even if an existing pair has the same name
On success, the CGI program returns a blank page
If something goes wrong and the new pair can't be written,
print out "ERROR," followed by a description of the problem
Your can use any language you like, though if you want to use something besides C, Python or Perl you'll need to install it.
Here is a skeleton CGI program in C that shows how to obtain the query string and output a page.
It also has a couple helper functions for parsing out parameter values from the string.
Part 3.
Benchmark your CGI program using the Apache benchmark utility ab.
The utility is located in /usr/local/apache2/bin.
Type ab with no arguments to get a list of its features.
Complete this readme.txt file with the requests per second you measure using ab connecting locally to your server (that is using the base URL http://127.0.0.1).
Submission.
I will be testing your application by logging into your sever, starting Apache and then going to the get and set pages.
You should also submit your CGI program source code, get.html, set.html and readme.txt to the Moodle dropbox.
The Moodle timestamp is the completion time for the assignment.