Setting up MC/Rev as a CGI
an iBlog (instructional blog)
|
Red Had Linux 7.2
|
The first thing I discovered is that ISPs (in general) don't want you to use anything but Perl as a CGI; their tech support people are trained in it, they have tools to help you get it working, and, for the most part, they don't understand why anyone would want to use anything else.
So I turned to my attention to all the notes I've collected over the years on using MC as a CGI and also spoke with Richard Gaskin of Fourth World, who is currently using MC as a CGI. Basically the steps boil down to these:
The name of the file was simple.cgi. I had made sure that since I was uploading to a UNIX server that I saved the file with UNIX line endings (I use a Windows tool called TextPad that does this for me).#!mc on startUp put "Hello World!" into tResponse put "Content-Type: text/html" & crlf put "Content-Length:" & (the length of tResponse) & crlf & crlf put tResponse end startUp
The basic idea is that you call on this script file the same way as you would call on a Perl CGI (as part of the URL) and according to the code above, I should get "Hello World!" showing in my web browser when I execute this from the Address field of my browser (Internet Explorer 6/Windows, if you must know):
http://www.sonsothunder.com/cgi-bin/simple.cgi
Well, when I tried, it I got this:
This is the infamous "Internal Server Error 500" window that you get which tells you there's a problem with your CGI. It doesn't tell you what is wrong; just that there's something wrong.
So I tried a few things and eventually asked people on the list what to do, including technical support at my ISP. Brian Yennie suggested I use Telnet to go and see if I can execute the CGI from the command-line by going to the directory and typing ./mc simple.cgi. I tried that, and got the error message:
linux: error while loading shared libraries: libXext.so.6: cannot open shared object file: No such file or directory
This made me think that there was something wrong with a path I was providing, until Andu stepped up and suggested I
use Telnet, go to the cgi-bin directory, and then check to see what libraries might be missing by doing a
ldd mc command, and here's what it returned:
libXext.so.6 => not found
libX11.so.6 => not found
libm.so.6 => /lib/i686/libm.so.6 (0x40119000)
libc.so.6 => /lib/i686/libc.so.6 (0x4013c000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
This told me I was missing two necessary library files for MetaCard to run as a CGI. I checked with my ISP to see
if I could upload these files, and he informed me that I could upload them anywhere so long as I added the path
to the location where the uploaded libraries could be found to my /etc/ld.so.conf file. Andu was
kind enough to give me a copy of the two library files I was missing, so I created a directory at
/usr/home/lib, uploaded the files there, and added usr/home/lib to the
/etc/ld.so.conf file. Finally, I ran ldconfig (which you can do at any command prompt), which attached the two library
files and made them available.
I then went back and tested by CGI from the Telnet command line by going to my cgi-bin directory and typing ./mc simple.cgi. Lo and behold, the words "Hello world!" appeared in my terminal! I excitedly tested this in my browser, and sure enough, it worked.
Posted 1/24/2003 by Ken Ray
Close this window | Print this window |