Welcome to the CGI How-To.

Written by Mel Gorman

This page goes through the first steps of setting up CGI for your page. First, create a directory called cgi-bin in your public_html directory. This is the directory that the server will run CGI from. If you have a CGI program in any directory other than cgi-bin or it's sub-directories, you will get server errors when you try and run them.

Making programs run as CGI

Any CGI program that you use must be in this cgi-bin directory and they must all have the execute bit set. The execute bit tells the server that the file is a program and not just another plain file. To set the execute bit type

chmod a+x prog.cgi

where prog.cgi is your cgi script. Now when you access prog.cgi through the browser, it will be executed rather than read. To set all files in the cgi-bin directory, type

chmod a+x --r *

This will make all files in the current directory and sub-directories executable. Now the browser will cause the files to execute as cgi.

CGI Extensions

CGI written in different languages sometimes have different extensions to distinguish them. However on skynet, the only extension is .cgi. Make sure all files you intend to run as CGI have this extension otherwise it will not run. Not that this isn't always the case and another server might have many extensions for each type of CGI program.

Finish Up

Thats all there is to setting up CGI for your home page. To learn about writing CGI, look around the internet for related books. There are many e-books around that deal with the topic for various languages. Also, be sure to secure your CGI scripts for bugs and the like so that a malicous user won't mess up your account through a buggy script. Other than that, you are ready to start your web pages.

Back To The Table Of Contents



Skynet - University of Limerick Computer Society
XHTML 1.1 :: CSS 2 :: 508 :: © 2009
Disclaimer: Neither Skynet administration nor University of Limerick accept responsibility for users site content.