LAB SESSION 1: CGIs =================== 0.- Understand what CGIs are and how they work. A good place to start is: http://www.jmarshall.com/easy/cgi/ 1.- Install Apache. Download Apache from: http://docencia.ac.upc.edu/FIB/PXC/lab/_cgi/apache-pxc.tar.gz Some of the directories of Apache are: apache/htdocs Where the html pages are apache/cgi-bin Where the CGIs are apache/conf Where the configuration files are apache/bin Where the binary files are 2.- Install the examples of CGIs to the 'cgi-bin' directory: http://docencia.ac.upc.edu/FIB/PXC/lab/_cgi/cgi-examples.tar 3.- Install the html files 'htdocs' directory: http://docencia.ac.upc.edu/FIB/PXC/lab/_cgi/pxc-html_en.tar.gz 4.- Configure Apache: The configuration file is '/apache/conf/httpd.conf'. ServerRoot "/PATH/apache" Specifies in which directory is Apache Port 2345 Specifies in which port Apache will listen 5.- Start Apache: ./apache/bin/httpd -f ./apache/conf/httpd.conf 6.- Check that it's working by typing the 'http://localhost:port' URL in a web browser. 7.- Create two CGIs that use the html files provided in section 3 to implement a car rental system. Htdocs/rent.html invokes cgibin/rent with the GET method. Htdocs/list.html invokes cgi-bin/list with the method POST. When invoking 'list' CGI it should list all the car rents registered through the 'rent' CGI. You can choose in what language you want to implement both CGIs. APPENDIX ======== With these two examples you can get a better picture of how the GET and POST methods work: GET === > bash $ export QUERY_STRING="a=1&b=2" $ export REQUEST_METHOD="GET" $ ./query Content-type: text/html
a = 1
b = 2
a = 1
b = 2