Cgi-bin & Greenstone

apps

#1

Hi,

I just installed the greenstone package and it asks me to do the following:

  • Don’t forget to configure your webserver to treat
    …/gsdl/cgi-bin as a cgi executable directory.
    For the Apache webserver this means adding the following
    ScriptAlias directive to your httpd.conf configuration file.

ScriptAlias /gsdl/cgi-bin/ “…/gsdl/cgi-bin/”
<Directory “…/gsdl/cgi-bin”>
AllowOverride None
Options None
Order allow,deny
Allow from all

  • Don’t forget to configure your webserver to treat
    …/gsdl as a web accessible directory.
    For the Apache webserver this means adding the following
    Alias directive to your httpd.conf configuration file.

Alias /gsdl/ “…/gsdl/”
<Directory “…/gsdl”>
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

Now, I followed the steps in http://wiki.dreamhost.com/CGI to get the cgi-bin scripts running, but when I try to point my browser to one of them, the browser does not execute it, but rather asks me whether I would like to download the file…

In addition, I’m also not sure what to do about making the directory ‘web accessible’…

Any suggestions? Help would be very much appreciated!

Thanks,

Fabian


#2

Web accessible just means that the directory is in a place that you can get to from your browser. Assuming you’ve placed it inside of your document root (normally /home///), you should be fine. Since it’s asking you if you want to download the file, that probably means you’ve done this just fine.

It sounds like you have something misconfigured in your .htaccess which leaves Apache thinking that your scripts are actually static files of some unknown type. Can you post back telling us what your actual directory structure looks like as well as the contents of your .htaccess file? Also, could you post up the URL to your site so that we can take a look for ourselves to try to see what’s wrong?


#3

Thanks a lot for your help, very much appreciated! I listed all the info below, just let me know if you need more.

However, it might be that I got closer to localise the problem. I can browse without problems through the folder, where greenstone is installed (www.exre.org/gsdl), as well as all of its subfolders - apart from the cgi-bin folder.

But I don’t know why access is forbidden: the ls -l output is the same as in the case of the accessible sub-folders, and .htaccess does not establish any restrictions (at least as far as I can see).

It would be great if you could help me with this!

Thanks,

Fabian


The folder where greenstone is installed:

/home/exre/exre.org/gsdl

The cgi-bin folder:

/home/exre/exre.org/gsdl/cgi-bin

The web address:

www.exre.org/gsdl/

Here is the result of ls -l -a in cgi-bin:

total 6648
drwxr-xr-x 2 exre pg1669720 4096 2008-05-18 09:08 .
drwxrwxr-x 12 exre pg1669720 4096 2008-05-18 09:07 …
-rw-r–r-- 1 exre pg1669720 49 2008-05-19 04:33 .htaccess
-rwxr-xr-x 1 exre pg1669720 210191 2008-05-18 08:49 CGI.pm
-rwxr-xr-x 1 exre pg1669720 90 2008-05-18 08:49 getior
-rwxr-xr-x 1 exre pg1669720 32120 2008-05-18 08:49 gliserver.pl
-rwxr-xr-x 1 exre pg1669720 5798 2008-05-18 08:49 gsdlCGI.pm
-rwxr-xr-x 1 exre pg1669720 1077 2008-05-18 08:57 gsdlsite.cfg
-rwxr-xr-x 1 exre pg1669720 4126304 2008-05-18 08:51 library
-rwxr-xr-x 1 exre pg1669720 2379764 2008-05-18 08:51 oaiserver
-rwxr-xr-x 1 exre pg1669720 3195 2008-05-18 08:49 readresults.cgi
-rwxr-xr-x 1 exre pg1669720 3240 2008-05-18 08:49 savereport.cgi
-rwxr-xr-x 1 exre pg1669720 1344 2008-05-18 08:49 trackreport.cgi
-rwxr-xr-x 1 exre pg1669720 4031 2008-05-18 08:49 usabcgi.pm

User and default group (which includes exre) are correct, and I did chmod 755.

Here the entry for the cgi-bin folder itself and, for comparison, for the bin folder:

drwxr-xr-x 5 exre pg1669720 4096 2008-05-18 08:51 bin
drwxr-xr-x 2 exre pg1669720 4096 2008-05-18 09:08 cgi-bin

Here is the content of the .htaccess file within the cgi-bin folder:

Options +ExecCGI -Indexes
SetHandler cgi-script

(Eventually, I would like to restrict access to certain intranet users.)

Here is the error.log for my attempt to go to www.exre.org/gsdl/cgi-bin/library (as required to start the library database):

[Mon May 19 04:07:18 2008] [error] [client 84.227.31.49] Premature end of script headers: library
[Mon May 19 04:07:18 2008] [error] [client 84.227.31.49] File does not exist: /home/exre/exre.org/internal_error.html
[Mon May 19 04:07:18 2008] [error] [client 84.227.31.49] File does not exist: /home/exre/exre.org/favicon.ico, referer: http://www.exre.org/gsdl/cgi-bin/library
[Mon May 19 04:07:18 2008] [error] [client 84.227.31.49] File does not exist: /home/exre/exre.org/missing.html, referer: http://www.exre.org/gsdl/cgi-bin/library

(I take it that the last three messages concern the fact that I don’t have any setup for displaying error messages.)


#4

Sorry about the delay answering back, I’ve been rather swamped with stuff the past couple days. The good news is that I think I can clear up at least one mystery and maybe suggest a next step for the other.

The restriction is the ‘Options -Indexes’ in the cgi-bin folder’s .htaccess. When Apache tries to decide what to display for a directory, it starts by trying to display any DirectoryIndex, then by generating a folder index, or finally generating a 403 Forbidden error. In your case, you don’t have a valid DirectoryIndex and by using ‘Options -Indexes’ you’ve told Apache to never generate a folder index, which leaves the error as its only remaining option.

[quote]Here is the error.log for my attempt to go to www.exre.org/gsdl/cgi-bin/library (as required to start the library database):

[Mon May 19 04:07:18 2008] [error] [client 84.227.31.49] Premature end of script headers: library
[Mon May 19 04:07:18 2008] [error] [client 84.227.31.49] File does not exist: /home/exre/exre.org/internal_error.html
[Mon May 19 04:07:18 2008] [error] [client 84.227.31.49] File does not exist: /home/exre/exre.org/favicon.ico, referer: http://www.exre.org/gsdl/cgi-bin/library
[Mon May 19 04:07:18 2008] [error] [client 84.227.31.49] File does not exist: /home/exre/exre.org/missing.html, referer: http://www.exre.org/gsdl/cgi-bin/library

(I take it that the last three messages concern the fact that I don’t have any setup for displaying error messages.)[/quote]
This, however, is still strange. You’re right about those last three errors, so there’s no reason to worry about them. It’s that first error, and the related 500 Internal Server Error returned to the browser, that actually do qualify as a problem. At this point, I’ve got two things to suggest.

First, because of how Dreamhost handles CGI scripts, you can probably remove the ‘Options ExecCGI’ from your .htaccess. While I don’t think this will be the cause of the problem, it is unnecessary in light of the fact that CGI scripts can run anywhere on Dreamhost.

The second suggestion I have is to log in using SSH and try running the library script from the shell. To do this, simply go to the cgi-bin directory and type ./library into the shell. Pay careful attention to the output to make sure that it does everything it’s supposed to do. Since you’re getting a “Premature end of script headers” error, be sure to pay special attention to the headers generated by the script. With luck, you’ll be able to see something that will suggest a next step.

Best of luck tracking the problem down, and don’t hesitate to post back if you need more help (or to tell us the solution)! :slight_smile:


#5

Thanks a lot for clearing up things!

I tried already executing ./library from the shell, and I just get the response ‘Killed’. No headers generated, it seems.

Also, it does not change when I comment out the options in the .htaccess file. And even if I add ‘Options +Indexes’, I can’t even access the folder cgi-bin via my browser.

So I’m unfortunately still clueless…


#6

Well, I spent some time today messing around with this thing since you got me really quite curious what the trouble was. I can confirm that this thing immediately gets smacked with a KILL signal whenever I try to run it in the shell. Unfortunately, I don’t actually know what in Linux generally or on Dreamhost’s setup in particular would cause an event like that.

In an attempt to work around it, I tried compiling Greenstone from source. Unfortunately, the compilation turned out to be fairly resource intensive, so it just gets killed by procwatch.

You may want to start looking at some different software to fit your needs…


#7

Yes, you’re probably right… I found some alternative which seems much simpler to install (called ‘refbase’), but what is so nice about greenstone is that it allows you to search within the pdfs and docs in your library…

Anyway, I won’t be giving up completely on installing greenstone and keep you posted if I should succeed some day…

Thanks again for your time & sorry to have left you with an unstilled curiosity! :wink: