CGI Tutorials and Resources
CGI — Common Gateway Interface — is a protocol for connecting communicating between a web server and an application running on the host server. CGI technology was an important driver for the first wave of truly interactive websites in the late 1990s. While the original CGI protocol has mostly fallen into disuse, its descendant still power a large portion of the world wide web.
CGI is one of the oldest technologies of the interactive web, and there are a lot of tutorials about it. These are some of the best, each one offering a slightly unique viewpoint on CGI scripting.
- CGI Tutorial for Beginners is a four-part series of tutorials, covering CGI basics, mostly in Perl.
- Perl and CGI Tutorial from Tutorials Point provides a clear, step-by-step introduction to CGI.
- CGI Scripting Tutorial from the University of Minnesota provides a great tutorial on using CGI with Python, Perl, Ruby, and Bash.
- Dynamic Content with CGI is a highly technical, detailed tutorial on CGI from Apache.
- Beginner's Tutorial for CGI Perl Language provides a gentle introduction to CGI scripting in Perl.
- CGI Made Really Easy is exactly what it sounds like, with an emphasis on processing simple HTML forms in Perl.
- CGI Programming Is Simple is an encouraging introduction to CGI, designed to make it seems as easy as it really is.
- Creating and Processing Web Forms with CGI is a very detailed explanation of using CGI along with HTML forms.
- This CGI Tutorial from Codepoint.net is an easy-to-follow walkthrough using Python 2 as the scripting language.
- CGI for the Non-Programmer is a very basic tutorial designed for people without any experience. By the end of it, you'll have a decent understanding of Perl, CGI, and Unix fundamentals.
- Getting Started with CGI Programming in C is one of the few CGI tutorials that doesn't focus on a scripting language like Perl or PHP. C is not generally a good language for CGI programming, but this tutorial might be helpful for people already familiar with CGI who are just starting to learn C.
- The Most Simple Intro to CGI is exactly what it promises. It even has pictures to help explain "how the internet basically works." This is a great guide for the easily perplexed.
- What is CGI and How To Use Your CGI-BIN is a casual series of Linux- and Perl-based CGI tutorials.
- CGI Made Really Easy promises to get you from knowing nothing about CGI to having a completed script in thirty minutes.
- Matt Kruse's Intro to CGI is for people who think that CGI stands for "Can't Get It-to-work."
- Web Programming 101 gives a really good introduction to how the internet works, explains the problems that CGI was trying to solve, and some of the problems that CGI created. Then it discusses a number of different models for how a client (browser) and server should communicate.
- Perl CGI Tutorial: First lesson on Perl programming provides an overview of CGI and also an introduction to Perl programming — a great resource for beginners.
- CGI Programming 101 is a website dedicated to learning CGI. They have several complete tutorials, with information on working with various operating systems.
Reference and Resources
Most of the CGI-related pages on the internet are very old, and only some of them are even remotely relevant for today. We have combed through the available resources, to provide you with only the ones that are useful (or, at least, interesting).
- The W3C's Official Page on CGI provides historical information on the standard and links to various documents related to the specification.
- CGI-Tools is a collection of Python tools for quick CGI script development.
- The Cgi-lib.pl Library for Perl makes CGI scripting in Perl very easy.
- Python-CGITools is a Python library designed to enhance Python's standard CGI library.
- This collection of Perl scripts can help you get the most out of your CGI-based web site.
- Free CGI Scripts is a listing of CGI script repositories.
- Webdeveloper.com List of CGI scripts, mostly written in Perl, for a variety of purposes.
- CGI Resource Index is a site that provides thousands of CGI scripts, along with tutorials, links, and other resources.
Books on CGI
- CGI Programming with Perl (2000), by Guelich, Gundavaram, and Birznieks, from O'Reilly, is one of the best books on the topic. It is relatively advanced, and is aimed at professional programmers.
- CGI Programming on the World Wide Web (1996), by Shishir Gundavaram, is another excellent book on the topic from O'Reilly. This is not as comprehensive a resource as the one listed above, but it's still packed full of information.
- Cgi How-To: The Definitive Cgi Scripting Problem-Solver (1996), by Asbury, Mathews, and Sol, is a classic, imminently practical how-to book on CGI, covering Python and C.
- Instant Web Scripts With Cgi Perl (1996), by Sol and Berznieks, is a "cook book," of useful CGI scripts.
- CGI Developer's Guide (1996), by Eugene Eric Kim, is a comprehensive guide and reference book for working with CGI in Perl.
- CGI Manual of Style (1996), by Shevchik and McDaniel, is a unique book. It examines several popular CGI scripts, pointing out how they were written and providing pointers for writing CGI scripts with good style.
- Perl and CGI for the World Wide Web (2001), by Elizabeth Castro, is part of the Visual QuickStart series, explaining CGI and Perl programming in a simple, easy-to-follow format.
- Sams Teach Yourself CGI in 24 Hours (2002), by Rafe Colburn, is a very fast introduction to CGI, ideally suited for programmers with some Perl experience.
- CGI: Internet Programming in C++ and C (1997), by Mark Felton, is one of very few books that provides information on CGI with low-level operating system languages C and C++.
- CGI Developer's Resource (1997), by J M Ivler, is designed as a sort of cook-book or desk reference, containing hundreds of CGI scripts, with comments and explanations.
- CGI Programming 101 (2000), by Jacqueline D Hamilton, takes the reader from very basic CGI introduction to advanced concepts, including connecting to databases and writing custom Perl modules.
- CGI Programming With Tcl (1999), by David Maggiano, is a rare book on CGI, showing how to use the technology with the Tool Command Language.
- Writing CGI Applications with Perl (2001), by Meltzer and Michalski, is a highly practical book on CGI and Perl, covering all of the relevant use cases and concerns, including databse connections, security, and RSS.
- The CGI/PERL Cookbook (1997), by Patchett and Wright, contains 20 popular CGI scripts, and provides line-by-line explanations of them.
- The Web Wizard's Guide to Perl and CGI (2002), by David A Lash, covers both practical coding concerns like other books, but also discusses usability, audience retention, and user data analytics.
Should I Use CGI?
In modern web development, CGI has largely been replaced by a large number of alternatives. For conventional web server scripting, two descendant of CGI: Fast CGI and Simple CGI have taken over. Additionally, many web development platforms like Node.js or Java act as their own web server.
Further Reading and Resources
We have more guides, tutorials, and infographics related to coding and development:
- PHP Introduction and Resources: this is one of the biggest coding languages on the web.
- Composing Good HTML: this is a solid introduction to writing well-formed HTML and using HTML validator software.
- CSS3 — Intro, Guides & Resources: this is a great place to start learning webpage layout.
What Code Should You Learn?
Confused about what programming language you should learn to code in? Check out our infographic, What Code Should You Learn? It not only discusses different aspects of the languages, it answers important questions such as, "How much money will I make programming PHP for a living?"