Docs Blog Get-it

How to Setup REBOL CGI for Apache Servers

By Kurt Sassenrath
Revised: 16-Sep-2010


This 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. This example is for Windows XP, but the process is similar for Linux and other systems.

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:

  1. Install Apache
  2. Configure Apache
  3. Add REBOL
  4. Add Your Script
  5. Test It

Let's get to it, shall we?

Install Apache

The first thing you need to do is install the Apache 2.2 HTTP Server program on to your computer. Apache can be downloaded at 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 Apache

Once 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

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.


Now, move a copy of REBOL/Core into the "CGI-bin" directory, located in the "Apache2.2" folder.

Add Your Script

Next, 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

print "Content-type: text/html^/"
print [<html><body> "REBOL CGI Works!" 
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

This line of code tells Apache where to find REBOL, so it can process CGI requests.

At the end of the line, the "-cs" simply tells us that:

cAllow CGI processing
sDisable security, so we can save files with the data collected.

Test It All

Create 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*

Make sure you do not simply click on your html file to open it. It will be in "file mode," which when your form is submitted, the result will simply be your .CGI file displayed in text format, which is not what we want.

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!

About | Contact | PrivacyREBOL Technologies 2021