First, I added this config in Apache's httpd.conf for a particular directory:
- Code: Select all
Options Indexes FollowSymLinks Includes +ExecCGI
AddHandler cgi-script cgi
Then I got a "python.cgi" script working to verify that CGI worked:
- Code: Select all
#!/usr/bin/python
import time
stamp = time.asctime()
print 'Content-Type: text/html\r\n\r\n'
print '<html>'
print '<body>Hello from Python at %s</body>' % stamp
print '</body>'
There was no binary install of Novell Mono for my distro, so I grabbed the Mono 2.4 source tarball and did:
- Code: Select all
./configure --prefix=/usr/local
make
make check
make install
Which went fine. I then installed the last Cobra release (2009-04-07) and attempted the same type of CGI script with Cobra:
#!/usr/local/bin/cobra
class X
def main is shared
print 'Content-Type: text/html\r\n\r\n'
print '<html>'
print '<body>Hello from Cobra at [DateTime.now]</body>'
print '</body>'
This failed. It even failed to run at the command line with "./cobra-test.cgi" where almost every line generated an error, but not one from the Cobra compiler. Execution perms and file ownership were correct. Since it looked like bash was trying to read the source, I read the wikipedia page on shebang and discovered that the shebang line cannot point to another script. The "cobra" command is another script. But they say you can do this:
#!/usr/bin/env /usr/local/bin/cobra
It failed as a .cgi script though and the error log complained that "mono" could not be found. So I changed the "cobra" script to use the full path to mono:
- Code: Select all
#!/bin/bash
exec /usr/local/bin/mono "/usr/local/cobra/Cobra-0.8.0-post-2009-04-07/bin/cobra.exe" "$@"
That worked which got me to the next error:
- Code: Select all
[Sat Apr 11 17:31:12 2009] [error] [client 66.171.254.110]
[Sat Apr 11 17:31:12 2009] [error] [client 66.171.254.110] GThread-ERROR **: file gthread-posix.c: line 135 (): error 'Operation not permitted' during 'pthread_getschedparam (pthread_self(), &policy, &sched)'
[Sat Apr 11 17:31:12 2009] [error] [client 66.171.254.110] aborting...
[Sat Apr 11 17:31:12 2009] [error] [client 66.171.254.110] Premature end of script headers: cobra-test.cgi
Here is another script that cuts Cobra out. It works at the command line but chokes in Apache with the same GThread-ERROR:
- Code: Select all
#!/bin/bash
echo 'Content-Type: text/html'
echo ''
/usr/local/bin/mono
I'll check with the Mono discussion forums and see if they have anything to say.