Common Gateway Interface (CGI)

Definition

Web Servers Handle Requests

Lab
  • Create a file named hello.cgi in your document root directory, containing:
    print "Content-Type: text/plain\n\nHello world! (love, Perl)\n";
    Note: On Unix, your Perl script needs a "shebang".
  • Open this file in your browser with a URL starting with http://.
  • How does your server handle your browser's request? Does it copy or run your Perl script?

Running CGI Scripts

In httpd.conf (on NT) or srm.conf (on Unix), you define the condition(s) under which your server runs files instead of copying them.
Lab
  • Implement condition 2 and test it on hello.cgi.
  • Now, does the server copy or run your Perl script?