is this for
This is for those who would like to have basic
knowledge on CGI programming and requirements on running CGI
What you need to know
Basic Windows or Linux operation
is an acronym for Common Gateway Interface. It is a method of passing
data from a web browser to a database, document or other processes
for processing. The result will also be displayed on the web browser.
A CGI script is written in any language and Perl is used more often
when coding CGI scripts.
Components needed to Make CGI
CGI scripts reside in a server. A server is a program
that manages incoming requests from clients. A client is another
program that sends requests to the server for processing. The client
can be on the same machine or in another machine over the network.
The most popular server is the Apache Web Server. Apache has versions
for Linux and Windows (Yes there is a Windows version). For Windows
98, you have the Personal Web Server (PWS). You can also run your CGI
scripts in the PWS.
Setting up an Apache Server in Linux
you are running Linux, you probably have an Apache distribution in
your CD. If not, you can download it from the Apache Web site
you have downloaded the distribution, proceed to install it. To
install, you have to configure the compiler options and then compile
the source code. Once installed, you can configure it to process CGI
Installing Apache in Windows
Like the Linux
distribution, you can download the Apache Web server from their
Once downloaded, you can just run the downloaded file and it will
install the Web Server for you. You do not have to change any of the
configuration to run CGI scripts. The installation program will
create an Apache Web Server folder in your Start->Programs folder.
The items in the Apache Web Server folder allows you to start and
shutdown the installed Apache server. Try starting the Apache Server.
It should start a DOS Window and display this message:
You CGI scripts would, by default, be
read from the C:\Apace\CGI-BIN directory.
Setting up the
Personal Web Server in Windows
If you do not want to use
Apache, you can use the Microsoft Personal Web Server (PWS) in
Windows. PWS is in the Windows 98 CD and you can install it from
there. Once installed, you have to do some tweaking to run Perl CGI
scripts. Click Start->Run and then type regedit. This
starts the Registry Editor. Follow through these folders:
the following on the Top Menu:
defines an entry at the right Window of the Registry Editor. Change
this value to .pl. Then double-click on the entry you edited.
This will bring up the Edit String window. Type this on the Value
C:\perl\bin\perl.exe %s %s
sure that you specify the location of Perl in your system and type
the %s as is. This is case sensitive. Create another entry for
the .cgi extension.
Start the Personal Web Server and
select the Advanced icon. This should display the Advanced
options with a list of Virtual Directories.
Check if there
is a /cgi-bin directory. if there is none, create one. If
there is, double-click on it.
This displays an Edit Directory
Window. Change the Directory to where you want to put your CGI
Recommended is C:\Inetpub\wwwroot\cgi-bin. Also check
the Read, Execute and Scripts options. Then click the OK
Testing your first CGI Script
file (call it test.cgi) in your CGI directory (wherever you specified
it in PWS or Apache).
print "Content-type: text/html\n\n"; # should be as
print "Hello, world!";
Note that the last two lines
can be written as one line. I separated them because it looked like
two separate lines when displayed in this article.
browser and type this on the URL: