Cmps 356: Web Site Intialization
Description
The purpose of this assignment is to set up your web site on www.cs.scranton.edu in a safe secure manner and making sure your site is set up correctly to run cgi software.
UNIX
Set up
CGI
The Log
UNIX Editors
  • pico
  • vi
  • UNIX
    The department web server is Apache running under UNIX. We run the Apache web server using the SUExec option, which means that when the web server run a server side program in an account, it runs as the owner of that account.

    At first, this might sound a bit dangerous - anyone, anywhere in the world can run programs in your account, as you! On the other hand, it means that you can use the UNIX protection to keep items in your account since they only have to be visible to you and your group, not to all users.

    It also means you must be very careful about access permissions. Pay careful attention to all discussions about permissions.

    Frequently used UNIX Commands

    List files ls options mask
    a typical option is "-al"
    You may want to pipe the ls command if the directory is large
    ls -al *|more
    Change working directory cd options mask
    ../ takes you up one level
    Make directory
    mkdir name
    Remove directory
    rmdir name
    Editors pico filename [or] vi filename
    pico is very easy to use, vi uses lots of cntl codes
    Change access chmod options filemask
    Usual option is 755 (read=4, write=2, execute=1)
    Change group chgrp grpname filenmask
    The group must be your group for all web files for Apache to work correctly.

    Setting up your web site
    This is very easy.
    1. Log into one of the department machines.
    2. Create a directory called public_html.
    3. Check the protections on public_html. We recommend that the protection be set to 755, owner read/write/execute, group read/execute, others read/execute, or 750. Perform,

      ls -al pu*

      to check your access permissions and to check your group. Your group should be student.

    4. If you need to set protections, use

      chmod 755 file_name

    5. Create a "index.html" file in public_html.
    6. Set permissions on index.html. You may want to set permissions as 750.
    7. Check your site out by going to a web browser and accessing

      http://www.cs.scranton.edu/~yourlogon

      .If it does not work,

      • Look for typos
      • Check access protections
    CGI
    You are now ready to make sure that CGI (Common Gateway Interface) works in your account. This will be accomplished by copying a perl script into your account. Access the URL,

    http://www.cs.scranton.edu/~beidler/env.cgi

    with your web browser. It should return something like

    DOCUMENT_ROOT = /usr/local/apache/htdocs 
    GATEWAY_INTERFACE = CGI/1.1 
    HTTP_ACCEPT = image/gif, image/x-xbitmap, image/jpeg,
                               image/pjpeg, image/png, */* 
    HTTP_ACCEPT_CHARSET = iso-8859-1,*,utf-8 
    HTTP_ACCEPT_ENCODING = gzip 
    HTTP_ACCEPT_LANGUAGE = en 
    HTTP_CACHE_CONTROL = max-stale=0 
    HTTP_HOST = www.cs.scranton.edu 
    HTTP_IF_MODIFIED_SINCE = Mon, 13 Dec 1999 02:09:33 GMT 
    HTTP_USER_AGENT = Mozilla/4.6 [en] (Win98; I) 
    HTTP_XONNECTION = Keep-Alive 
    PATH = /usr/local/bin:/usr/bin:/bin 
    QUERY_STRING = 
    REMOTE_ADDR = 208.169.102.230 
    REMOTE_PORT = 50880 
    REQUEST_METHOD = GET 
    REQUEST_URI = /~beidler/env.cgi 
    SCRIPT_FILENAME = /users/faculty/beidler/public_html/env.cgi 
    SCRIPT_NAME = /~beidler/env.cgi 
    SERVER_ADMIN = webmastr@cs.scranton.edu 
    SERVER_NAME = www.cs.scranton.edu 
    SERVER_PORT = 80 
    SERVER_PROTOCOL = HTTP/1.0 
    SERVER_SOFTWARE = Apache/1.3.6 (Unix) 
    To copy the CGI script that did this into your account, access the URL

    http://www.cs.scranton.edu/~beidler/env.pl

    with your browser. You should see,

    #!/usr/local/bin/perl
    
    print "Content-type: text/html\n\n";
    print "#<html>#<head>#<title>Envionmental Variables#</title>#</head>#<body>";
    for $key (sort keys %ENV){
       print "#<b>$key#</b> = $ENV{$key} #<br>\n";
    }
    print "#</body>#</html>";
    exit;
    in your browser. Save this file in your public_html directory as env.cgi.

    Use the ls command to check the group and permissions. The group should be your group name. The permissions should be set to 755. Once these are fixed, access the URL,

    http://www.cs.scranton.edu/~yourlogon/env.cgi

    and it should work. If it does not, check your group and permissions again.

    This page was last modified on Wednesday, 22-Nov-2000 21:01:57 EST
    Submission
    Due:
    How to submit:
    Email to beidler@cs.scranton.edu
    Subject Line:
    Place on the subject line "web 1". It is very important to me that you do this precisely because I use the subject line to filter my email. Failure to do this correctly may result in a grade reduction.
    What to Submit:
    • Place in the email message the full URL of your web site,

      http://www.cs.scranton.edu/~login

    • Attach your program log.
    The Log
    You will be asked to keep separate logs for each programming assignment and submit these logs with the assignments. Do yourself a favor, don't fake the logs. Do your best to keep them while you are writing your program. The logs don't have to be elaborate, but try to make them precise.

    Keep in mind that when you come to me for help, the first thing I will ask you to show me is your log. I will expect your logs to be more accurate than your memory with respect to what you were doing. Sometime, the log will be a good clue as to what went wrong, and when it went wrong. It will make it easier to correct your situation.

    Logs should also contain analysis and design information.

    UNIX Editors
    There are several editors available on the unix boxes, vi, pico, and emacs, to name three. All three of these are not window based, but are solid reliable editors. We include here a brief discussion of two of them, vi and pico. The cursor control keys work with both of these editors. Both editor use control codes, holding down the control key while pressing a second key. vi is more versatile than pico, but pico uses the last two lines on the screen to present the basic control codes, hence you don't have to memorize them.

    pico

    If you are not very familiar with the unix environment, I strongly recommend you use pico. It is very easy to use. For example, while in public_html, entering the command

    pico env.cgi

    displays
       UW PICO(tm) 2.9                 File: env.cgi
    
    #!/usr/local/bin/perl
    
    print "Content-type: text/html\n\n";
    print "#<html>#<head>#<title>Envionmental Variables#</title>#</head>#<body>";
    for $key (sort keys %ENV){
       print "#<b>$key#</b> = $ENV{$key} #<br>\n";
    }
    print "#</body>#</html>";
    exit;
    
    
    
    
    
    
    
    
    
                                    [ Read 9 lines ]
    ^G Get Help  ^O WriteOut  ^R Read File ^Y Prev Pg   ^K Cut Text  ^C Cur Pos
    ^X Exit      ^J Justify   ^W Where is  ^V Next Pg   ^U UnCut Text^T To Spell   
    Note the display of the control codes at the bottom, hence nothing to memorize.

    vi

    With vi, you must learn the codes. It is not that difficult. Special roles are given to special keys;
    esc
    This places the editor in command mode
    :
    from command mode, this idicated a command will follow
    i
    Puts the editor in inset mode
    While in the public_html directory, the command

    vi env.cgi

    displays
    #!/usr/local/bin/perl
    
    print "Content-type: text/html\n\n";
    print "#<html>#<head>#<title>Envionmental Variables#</title>#</head>#<body>";
    for $key (sort keys %ENV){
       print "#<b>$key#</b> = $ENV{$key} #<br>\n";
    }
    print "#</body>#</html>";
    exit;
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    Note that the window contains no information about the editor. Entering the key sequence

    [esc]:h[enter]

    displays help information,

    +=+=+=+=+=+=+=+
    To see the list of vi commands, enter ":viusage"
    To see the list of ex commands, enter ":exusage"
    For an ex command usage statement enter ":exusage [cmd]"
    For a vi key usage statement enter ":viusage [key]"
    To exit, enter ":q!"
    Press any key to continue [: to enter more ex commands]:   
    Follow these commands for more information.