----------------------- Lab #05 for NET2003 due February 19, 2008 (Week 6.5) ----------------------- Remember - knowing how to find out an answer is more important than memorizing the answer. Learn to fish! RTFM! (Read The Fine Manual) Global weight: 3% of your total mark this term. Due date: before 14h00 (2pm) Tuesday February 19 (Week 6.5) The deliverables for this lab exercise are to be submitted online on the Course Linux Server using the "netsubmit" method described in the lab exercise description, below. No paper; no email; no FTP. Late-submission date: I will accept without penalty lab exercises that are submitted late but before 14h00 (2pm) on Wednesday, February 20. After that late-submission date, the lab exercise is worth zero marks. Lab exercises submitted by the *due date* will be marked online and your marks will be sent to you by email after the late-submission date. Lab Synopsis: Learn about a few basic Apache modules. Enable UserDir web pages in your Ubuntu account. Enable CGI scripting. Create an executable shell script. Turn the script into a dynamic web page in your Ubuntu account. NOTE: For full marks, keep your lines shorter than 80 columns in this course. Short lines allow for easy printing and side-by-side comparison of files on a screen. Where to work: the Course Linux Server and/or your Ubuntu caddy Easy access to Course Notes: See previous labs. ----------- Lab Details ----------- You may prepare this file on any Linux system using VIM. Files submitted in DOS/Windows format (e.g. using Notepad or other Windows editor) will not be marked. Though you can create and edit the file on any Linux system, you can only submit the file on the Course Linux Server. Sample output is given for the Course Linux Server. * For full marks, keep your lines shorter than 80 columns in this course. Short lines allow for easy printing and side-by-side comparison of files on a screen. * You may find it useful to create separate directories in your linus server account to store the files for each lab exercise, e.g. $ mkdir lab5 $ cd lab5 $ vim lab05answers.txt $ vim lab05script.sh Part I - Ubuntu maintenance ------ * As mentioned in class, make sure you have run the Update Manager and installed all current updates to your Ubuntu 7.10 (Gutsy) system. * Make sure you have installed the Apache web server on your Ubuntu system. (See "Upgrades and Enhancements" in the Notes file: installing_linux.txt ) Part II - Apache Configuration - lab05answers.txt ------- Copy this lab into file lab05answers.txt, strip away everything except the questions, and answer the questions, putting the answer lines underneath each question in the file. Do all the Apache configuration work in Part II on your Ubuntu caddy system. Apache configuration files are stored under directories with names that look like either /etc/http* or /etc/apache* on most Unix/Linux systems. (Unix/Linux keeps most configuration files under directory /etc/ ) We want to enable individual public_html directories in user accounts. 01. What shell command line will tell you the titles of all manual pages containing the keyword "apache"? (Hint: The command name is in the Notes file unix_command_list.txt ) 02. What is the name of the Apache Hypertext Transfer Protocol Server on your system? (Copy the name from the previous output.) 03. The (8) after each man page title means that the manual pages are in section 8 of the manual. What kind of manual pages are kept in section 8 of the manual? (Hint: man man ) 04. What shell command line will tell you in which directory the executable for the above Apache server resides? The answer should not depend on your $PATH variable. (Hint: The command name is in the Notes file unix_command_list.txt ) 05. In which directory are the Apache configuration files stored on your system? (Hint: This directory appears in the previous command output.) 06. What command line will show the version of Apache that is installed? (Hint: Read the man page for the Apache program to find the option you need.) 07. What command line will show the list of modules compiled into the Apache server? 08. What command line will show the list of Apache directives together with expected arguments and places where the directive is valid? 09. Do an Internet search and give the official URL for the "Apache HTTP Server Version 2.2 Documentation". 10. What Apache module is responsible for the public_html directories? (Hint: Use the search box on the Apache 2.2 Documentation page. The page you want to read is the "howto" page with the title "Per-user web directories". What is the Apache 2.2 module name?) 11. What shell command line will show the files under the Apache configuration directory that contain the string "public_html"? (Hint: The name of a command that looks for strings in files is given in Notes file unix_command_list.txt and the option to read all files under each directory recursively is in the man page for that command.) 12. Do an Internet search for the article "How To: Enable apache modules under Debian based system". (The page you want is on the debuntu site.) Read the article and then answer these questions: a) Give the list of modules that were compiled into Apache on your Ubuntu caddy system: c) Give all the lines containing the string "Include" in the main Apache configuration file. Use an option to have the lines prefixed by line number. (Hint: The name of a command that looks for strings in files is given in Notes file unix_command_list.txt and the man page for that command gives you the option name.) d) The article shows two lines "around line 115" in Ubuntu Dapper. In Ubuntu Gutsy (7.10), what are the line numbers for these lines? e) Give a command line that will count the number of enabled Apache modules on your system: f) Give a command line that will count the number of available Apache modules on your system: g) Follow the directions for "the debian way" on Page 2 of the article and use the given Debian command to enable the module that implements "public_html". Make sure you reload Apache. 13. Create a "public_html" directory in the home directory of your abcd0001 Ubuntu caddy account and create a file in public_html named README.txt with some text in it. 14. Verify that you can use a web browser to access either of these on your Ubuntu caddy system (replace abcd0001 with your Ubuntu name): http:///~abcd0001 # from off-machine http://localhost/~abcd0001 # using a local web browser Both should give you a directory listing showing the README.txt file, and you should be able to browse the contents of the file. Part III - copy a test script as a CGI file -------- Do all the Apache configuration work in Part III on your Ubuntu caddy system. 15. Browse this directory: http://10.50.254.148/~alleni99 Execute the test.sh or test.cgi script. Fetch the test.txt script into your Ubuntu caddy public_html directory and hard-link it to the name test.sh and test.cgi using the "ln" command (twice). No options are needed to "ln". All three names will refer to the same data. Make the script executable. 16. Edit the userdir.conf file and add "ExecCGI" to the list of Options. After the Options line, add this line to enable CGI scripts: AddHandler cgi-script .cgi .sh Reload Apache: sudo /etc/init.d/apache2 force-reload 17. Verify that you can use a web browser to access both files in your public_html directory on your Ubuntu caddy machine. The files ending in the CGI extensions will execute; the .txt will display the contents of the script (but will not execute the script). http:///~abcd0001/test.sh http://localhost/~abcd0001/test.sh Part IV - lab05script.sh ------- 18. Create an executable shell script named lab05script.sh that executes the command lines from Part II and displays the result as a web page. Follow the script layout model used in previous executable scripts, including the use of comments in the script. Make sure the Content-type line and the blank line that follows are the first two lines of output of your CGI script. 19. Copy the working script to the public_html directory of your Course Linux Server account. (You may need to create this directory first.) Make the script executable and test it there. You will access your script on the Course Linux Server using a URL similar to this: http://10.50.254.148/~abcd0001/lab05script.sh 20. Go back and finish the Purpose section comment at the top of the script. Scripts without your added comments will not be marked. NOTE: For full marks, keep your lines shorter than 80 columns in this course! Submission ---------- Submit the above two files (see below). Submission Standards: See Lab #1 for details. A. Make sure both files contain an Exterior Assignment Submission label. For full marks, lines must be shorter than 80 columns. B. Submit your files for marking as Lab 05 using the following *single* netsubmit command line exactly as given here: $ netsubmit 05 lab05answers.txt lab05script.sh Always submit *all* files at the same time for every submission. Files submitted under the wrong names are worth zero marks. P.S. Did you spell all the assignment label fields and file names correctly?