apache2cgirebolcgi-binrebol2

How to execute a Rebol CGI script on apache2


I'm trying to run a Rebol CGI script, on an apache2 server running on a GNU/Linux Debian Stable machine.

Here is my Rebol script:

  # pierre@autan: ~$        < 2013_05_29__17_35_22 >
dog /usr/lib/cgi-bin/test.cgi
#!/usr/bin/rebol -cs
REBOL []
print "Content-type: text/html^/"
print "coucou! (signé: Rebol)"

which fails:

  # pierre@autan: ~$        < 2013_05_29__17_21_18 >
lynx http://127.0.0.1/cgi-bin/test.cgi

returns:

                                                       500 Internal Server Error
                             Internal Server Error

   The server encountered an internal error or misconfiguration and was
   unable to complete your request.

   Please contact the server administrator, webmaster@localhost and inform
   them of the time the error occurred, and anything you might have done
   that may have caused the error.

   More information about this error may be available in the server error
   log.
     __________________________________________________________________


    Apache/2.2.22 (Debian) Server at 127.0.0.1 Port 80

The log says:

###ROOT### < 29/05/2013 17:02:45 >   root@autan:/# 
tail -1 /var/log/apache2/error.log
[Thu May 30 15:04:23 2013] [error] [client 127.0.0.1] Premature end of script headers: test.cgi

After reading the doc (http://httpd.apache.org/docs/trunk/fr/howto/cgi.html), I can run successfully this Perl script:

  # pierre@autan: ~$        < 2013_05_29__17_35_22 >
dog /usr/lib/cgi-bin/testpl.cgi
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "coucou! (signé: Perle)";

Now, I am wondering what goes wrong with the Rebol script...

I checked a few things:

The path to Rebol executable is correct: I can launch the script without explicitly calling the interpreter, directly from the shell:

  # pierre@autan: ~$        < 2013_05_30__14_07_36 >
/usr/lib/cgi-bin/test.cgi 
Content-type: text/html


coucou! (signé: Rebol)

Execution rights seem fine to me; they are the same for both files:

  # pierre@autan: ~$        < 2013_05_29__17_35_22 >
ll /usr/lib/cgi-bin/test*.cgi
-rwxr-xr-x 1 root root 97 mai   29 09:28 /usr/lib/cgi-bin/test.cgi
-rwxr-xr-x 1 root root 87 mai   29 09:26 /usr/lib/cgi-bin/testpl.cgi

Execution rights for Rebol executable seem fine to me:

  # pierre@autan: ~$        < 2013_05_30__14_07_36 >
ll /usr/bin/rebol 
-rwxr-xr-x 1 root root 1215652 déc.  30 22:50 /usr/bin/rebol

I'm using REBOL/View 2.7.8.4.2 2-Jan-2011.

Here is the apache2 configuration file that I modified:

###ROOT### < 29/05/2013 17:20:12 >   root@autan:/etc/apache2/conf.d# 
dog /etc/apache2/conf.d/httpd.conf 
#ScriptAlias magic/cgi-bin/ /var/www/magic/cgi-bin/
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
AddHandler cgi-script .cgi
Options

AddHandler magic .rhtml 
Action magic /cgi-bin/magic.cgi

<Directory "/var/www/magic/cgi-bin/">
        AllowOverride None
        Options ExecCGI MultiViews SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
</Directory>

<Directory "/usr/lib/cgi-bin/">
        AllowOverride None
        Options ExecCGI MultiViews SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
</Directory>

Note that I am not familiar at all with apache configuration.

Any idea?


Solution

  • have you tried using a Rebol/Core Version?

    Rebol/View needs to access the graphics system, even if it is only printing text, and maybe this isn't possible when started via Apache.

    (You'll get an error, if you start Rebol/View on a text-console, for example)