Question

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?

Was it helpful?

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)

Kind regards,

Ingo

OTHER TIPS

I think I may as well put the solution here, for completeness's sake. I simply followed Ingo's advice. Here is a dumb copy of my terminal, showing all steps:

  # pierre@autan: ~$        < 2013_05_30__19_52_58 >
cd rebol/telech/

  # pierre@autan: ~/rebol/telech$        < 2013_05_30__19_52_58 >
wget http://www.rebol.com/downloads/v278/rebol-core-278-4-2.tar.gz
--2013-05-30 19:53:27--  http://www.rebol.com/downloads/v278/rebol-core-278-4-2.tar.gz
Résolution de www.rebol.com (www.rebol.com)... 205.134.252.23
Connexion vers www.rebol.com (www.rebol.com)|205.134.252.23|:80...connecté.
requête HTTP transmise, en attente de la réponse...200 OK
Longueur: 224394 (219K) [application/x-gzip]
Sauvegarde en : «rebol-core-278-4-2.tar.gz»

100%[============================================================================================================================================>] 224,394      127K/s   ds 1.7s    

2013-05-30 19:53:29 (127 KB/s) - «rebol-core-278-4-2.tar.gz» sauvegardé [224394/224394]


  # pierre@autan: ~/rebol/telech$        < 2013_05_30__19_52_58 >
tar zxf rebol-core-278-4-2.tar.gz

  # pierre@autan: ~/rebol/telech$        < 2013_05_30__19_52_58 >
su
Mot de passe : 
###ROOT### < 30/05/2013 19:55:06 >   root@autan:/home/pierre/rebol/telech# 
cp releases/rebol-core/rebol /usr/bin/rebol_core
###ROOT### < 30/05/2013 19:55:06 >   root@autan:/home/pierre/rebol/telech# 
chmod a+x /usr/bin/rebol_core 
###ROOT### < 30/05/2013 19:55:06 >   root@autan:/home/pierre/rebol/telech# 
vi /usr/lib/cgi-bin/test.cgi
###ROOT### < 30/05/2013 19:55:06 >   root@autan:/home/pierre/rebol/telech# 
dog /usr/lib/cgi-bin/test.cgi 
#!/usr/bin/rebol_core -cs
REBOL []
print "Content-type: text/html^/^/"
print "coucou! (signé: Rebol)"

###ROOT### < 30/05/2013 19:55:06 >   root@autan:/home/pierre/rebol/telech# 

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


   coucou! (signé: Rebol)

=> it worked!

I don't want to have core as my default Rebol interpreter, this is why I prefer to have it explicitly named rebol_core. So that /usr/bin/rebol remains the rebol/view interpreter.

Thanks a lot, Ingo!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top