Default
Google

How to set-up REBOL CGI at free.prohosting.com

By Michal Kracik

A question that often repeats in the REBOL mailing list is: is it possible to use REBOL as a CGI scripting language at some free hosting service? Most hosting services do not give you CGI for free, but fortunately free.prohosting.com does. Their strategy is that if they are the best free hosting service, their happy users will help them find customers for their commercial professional hosting service at www.prohosting.com. REBOL is not installed on their server (Perl, the most popular CGI scripting language, is located in /usr/bin/perl), but they use the BSDI operating system, and there is a REBOL version for BSDI at http://www.rebol.com/downloads/rebol061.tar.gz. This document describes how to make REBOL work on their server.
 

1. Create your account

It's pleasant that ProHosting does not ask you for tons of personal information. You must enter your valid email address, because instructions how to use your account will be sent to you by email. Pay attention to the Username field, because the URL of your new website depends on it. For example, if your Username is rebol, the URL of your website will be http://hammer.prohosting.com/~rebol/ (I also got an alias http://also.as/rebol/). You should receive a confirmation email message immediately, then wait up to 4 hours for email instructions how to use your new account.
 

2. Prepare two necessary files on your computer

Since free.prohosting.com does not give you interactive Telnet access to their server, you must prepare all files locally, and then upload them by FTP to ProHosting. Download REBOL for BSDI from http://www.rebol.com/downloads/rebol061.tar.gz and unpack it. You will only need the REBOL executable, rebol. Since you cannot run REBOL interactively at ProHosting, rebol.r cannot ask you for network settings and create user.r for you, so there's no need to upload rebol.r.

Create the first test script, cgitest.cgi. It looks like:

#!/usr/home/web/r/rebol/cgi-bin/rebol --cgi
REBOL []

print "Content-Type: text/plain^m^j"
print "Hello world from REBOL"
print mold system/options/cgi
print system/version

Important: The suffix must be .cgi, not .r, or the ProHosting server will not run your script.

When you save the script, make sure that it has UNIX-like end of lines (single linefeed character, ASCII code 10). Particularly, this cannot be done with Windows Notepad or Wordpad. You should use a real text editor, or at least a smarter replacement for Notepad, like Metapad (which is even shorter than Notepad itself!). Alternatively, you can transfer text files in ASCII mode by FTP, it should do the conversion automatically.
Path in the first line of the script tells UNIX-like OSes where to find an interpreter, it is ignored by REBOL itself. Important: Set it to your own home directory where you will later download REBOL executable. You can look at the Account Administration page to see your home directory, it is not /usr/home1/rebol/.

3. Upload files by FTP and set their permissions

You need an FTP client that allows setting file permissions on remote UNIX operating systems. I use Windows Commander, but most FTP clients can do it, although with slightly different commands, see here how.

Upload two files, rebol and cgitest.r by FTP to the directory html/cgi-bin/.

Look at the URL similar to http://hammer.prohosting.com/~rebol/cgi-bin/cgitest.cgi in your browser. Again, use your own virtual home directory, not /~rebol/. You may also have your account on a different machine, like thor.prohosting.com.

You should now see the contents of cgitest.cgi script. The script was not run, because it does not yet have execute permission set. For more information about permissions see permissions guide in the unofficial prohosting FAQ.

Set permissions of cgitest.cgi by the FTP client:

chmod 711 cgitest.cgi

Refresh the page in your browser. The script still does not work, the server returns 500 Internal Server Error, because while it can run your script, it cannot yet run the REBOL executable.

Set permissions of rebol executable:

chmod 711 rebol
Note that BSDI (unlike Linux) allows executing files which cannot be read. This way you can hide rebol itself from reading, if someone tries http://hammer.prohosting.com/~rebol/cgi-bin/rebol, he gets an error message 403 Forbidden. If the permissions were 755, the binary file would be sent to user's browser (probably as a mess of characters, because the web server does not know its proper MIME type).

Now the script should run correctly and write something like:

Hello world from REBOL

make object! [
    server-software: "Apache/1.3.6 (Unix)"
    server-name: "hammer.prohosting.com"
    gateway-interface: "CGI/1.1"
    server-protocol: "HTTP/1.0"
    server-port: "80"
    request-method: "GET"
    path-info: none
    path-translated: none
    script-name: "/~rebol/cgi-bin/cgitest.cgi"
    query-string: ""
    remote-host: none
    remote-addr: "194.213.219.17"
    auth-type: none
    remote-user: none
    remote-ident: none
    Content-Type: none
    content-length: none
    other-headers: ["HTTP_ACCEPT" {image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*} "HTTP_ACCEPT_CHARSET" "iso-8859-1,*,utf-8" "HTTP_ACCEPT_ENCODING" "gzip" "HTTP_ACCEPT_LANGUAGE" "en,cs" "HTTP_HOST" "hammer.prohosting.com" "HTTP_USER_AGENT" "Mozilla/4.72 [en] (WinNT; I) via Smart Cache 0.40"]
]
2.2.0.6.1



Acquiring image from ProHosting Banner Exchange