![]() |
How to use REBOL CGI in Apache on Microsoft WindowsA tutorial by Kurt Sassenrath
IntroductionThis tutorial will simply teach you, the reader, how to use REBOL CGI on an Apache server, and how to configure Apache to accept REBOL CGI. After deciding to run Apache on my own computer, in order to learn REBOL CGI, I was surprised at how difficult it was to get CGI enabled. After an hour or so, I managed to get my first CGI script to run correctly on my computer. This is written to help you save time. Here are the steps I will describe below:
Let's get to it, shall we?
Install ApacheThe first thing you need to do is install the Apache 2.2 HTTP Server program on to your computer. Apache can be downloaded at http://httpd.apache.org/download. Make note of where you installed it on your computer. For instance, I installed my copy to the following address: C:\Program Files\Apache Software Foundation\Apache2.2
Configure ApacheOnce installed, you will need to configure Apache so that it recognizes CGI. Browse to where you installed Apache, then open the "conf" folder. Inside, edit the file "httpd.conf". This is where the entire Apache server is configured, so be careful when editing it. In your editing program, search for "CGI" until you find the following:
<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/CGI-bin">
AllowOverride None
Options None <-- change this line to 'Options ExecCGI'.
Order allow,deny
Allow from all
</Directory>
Next, continue searching for "CGI" until you come across: #AddHandler CGI-script .CGI Simply remove the '#' sign from the line, so it reads: AddHandler CGI-script .CGI Save your new config file, then restart Apache.
Add REBOLNow, move a copy of REBOL/Core into the "CGI-bin" directory, located in the "Apache2.2" folder.
Add Your ScriptNext, we have to put our REBOL CGI scripts in the "CGI-bin" directory of the Apache server. I will provide a simple script that reads forms for you: #!"C:/Program Files/Apache Software Foundation/Apache2.2/CGI-bin/rebol.exe" -cs REBOL [] print "Content-type: text/html^/" print [<html><body> "REBOL CGI Works!" <p> mold read-CGI </body></html>] Notice the first line of the program: #!"C:/Program Files/Apache Software Foundation/Apache2.2/CGI-bin/rebol.exe" -cs At the end of the line, the "-cs" simply tells us that:
Test It AllCreate an HTML page with a simple form in it. The form action will look something like this: <form action="/CGI-bin/CGItest.CGI" method="POST"> "CGItest.CGI" is the name of your CGI file, which must be in the CGI-bin folder. Next, we must put our HTML file into the "htdocs" folder, once again inside the Apache2.2 folder. After you put your HTML document in this folder, open your web browser and type the following in the address bar: http://localhost/*name of your html file here* If all has gone well, you should have a simple Apache server running with CGI enabled! Give yourself a pat on the back! Thanks for reading! If you have any questions, you can reach me at the above address. |
![]() |
Updated 10-Mar-2007, WIP Wiki, REBOL/Core 2.5.58.4.2 - Copyright 2005 REBOL Technologies - WWW.REBOL.COM - Edit |