You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Geoffrey Gallaway <ge...@sloth.org> on 2000/06/26 04:33:01 UTC

mod_perl and BerkeleyDB

I've been trying to get BerkeleyDB and mod_perl to work together for a
web database. I'm using BerkeleyDB version 3.1.14 on a RedHat 6.1 based
system with a stock kernel under apache 1.3.12 and mod_perl 1.21. I wrote
a simple script to open a berkeley database, read all variables then write
one.. When running under mod_perl I get the following error from apache:

[Sun Jun 25 20:38:28 2000] [error] Can't locate object method "TIEHASH"
via package "BerkeleyDB::Hash" at /home/httpd/cgi-bin/dbtest.pl line 9.

but when I run the same script (with mod_perl stuff commented out) under
the shell it works fine. The script is included below. I've tried running
the scipt as nobody to see if there is a permissions problem but the shell
version works fine. I'm at a complete loss as to what the problem might
be, any help would be *greatly* appreciated..

--- Begining of code ---

#!/usr/bin/perl -w
use Apache::Constants;		 # Commented out for shell version 
use BerkeleyDB;

my $r = Apache->request;	# Commented out for shell version
$r->content_type("text/html");	# Commented out for shell version
$r->send_http_header();		# Commented out for shell version

my $filename = "/tmp/testdb";
tie %h, "BerkeleyDB::Hash",
	-Filename => $filename,
	-Flags => DB_CREATE
	or die "Can't open $filename: $! $BerkeleyDB::Error\n";

while (($k, $v) = each %h) {
	print "$k -> $v\n";
}
$h{"apple"} = "red";
untie %h

--- End of code ---

Thanks in advance,
GeoffEG

-- 
Geoffrey Gallaway || This may seem a bit weird, but that's okay, because it
geoffeg@sloth.org || is weird.
D e v o r z h u n ||				-- Tom Christiansen 


Re: mod_perl and BerkeleyDB

Posted by Perrin Harkins <pe...@primenet.com>.
Geoffrey Gallaway wrote:
> 
> I've been trying to get BerkeleyDB and mod_perl to work together for a
> web database. I'm using BerkeleyDB version 3.1.14 on a RedHat 6.1 based
> system with a stock kernel under apache 1.3.12 and mod_perl 1.21. I wrote
> a simple script to open a berkeley database, read all variables then write
> one.. When running under mod_perl I get the following error from apache:
> 
> [Sun Jun 25 20:38:28 2000] [error] Can't locate object method "TIEHASH"
> via package "BerkeleyDB::Hash" at /home/httpd/cgi-bin/dbtest.pl line 9.

Did BerkeleyDB pass all tests?  Are you certain your perl doesn't have a
different libdb linked in?  (Use ldd on it to find out.)  RedHat comes
with an older libdb installed, so it can be tricky to make sure you're
egtting the right one.  I had to edit config.in from the BerkeleyDB
distribution before it worked for me.

The fact that this works under command-line scripts does point to your
mod_perl being linked to a different version of perl, as Vivek pointed
out.

- Perrin

Re: mod_perl and BerkeleyDB

Posted by Vivek Khera <kh...@kciLink.com>.
Are you sure that your mod_perl and command-line perl are the same
versions?  That is, is your mod_perl built after your latest upgrade
to perl, and is there only one version of perl on your system?