views:

72

answers:

4

I'm trying to use a Perl module from CPAN (AuthCookieDBI.pm to be specific) in a shared hosting environment.

I tried copying the .pm file to the directory I'm trying to use it with, and I have updated my .htaccess file as per the instructions on the AuthCookieDBI page, but my Apache log says:

Invalid command 'PerlModule', perhaps misspelled or defined by a module not 
included in the server configuration

This seems to be the line that causes the error:

PerlModule Apache2::AuthCookieDBI

According to the Apache:ASP FAQ this is caused because mod_perl is not installed; I'm on shared hosting (and so cannot do anything which requires root permissions), so is there nothing I can do about this?

A: 

Just put the unpacked the module to /path/lib/, below is the code you need in order to include this module.


#!/usr/bin/perl -w
use diagnostics;
use warnings;
use lib "$ENV{DOCUMENT_ROOT}/path/lib/";
unshift @INC , "$ENV{DOCUMENT_ROOT}/path/lib/";
use modulename;
Sorin Sbarnea
Manual installation of modules should only be done in unusual circumstances.
Ether
I'd say this is an unusual circumstance since we're using shared hosting. This answer should NOT be down voted since it actually works.
nbolton
Why would you put executable code under DOCUMENT_ROOT? That's a huge no-no. Put it in the non-browseable section of the file system.
brian d foy
One reason for that: being able to move your code to another server. Also "path" could contain a ".." inside.
Sorin Sbarnea
A: 

Normally you use the cpan tool to download and install the module for you. It should be installed into a standard location, such as under /usr/local/lib (see perl -V to see where your @INC directory is set up to be). When it is properly installed, your perl scripts will be able to find the module just as if it was a standard part of perl, with no special modifications necessary in mod_perl or apache configs. (You can also install modules to your home directory without requiring root permission. Instructions for that are contained in the CPAN FAQ.)

See:

Also, the CPAN FAQ itself has lots of information.

Edit: after everything, it would appear that the true answer to your question is "You can't; you need to find a different module to do what you need, that doesn't require mod_perl".

Ether
The sever has `cpan`, but I am not root.
nbolton
@Nick: You don't need root permission to install CPAN permissions. See the FAQ for specifying a different install directory; I've also added more references.
Ether
What about the "Invalid command 'PerlModule'" error? Should I ignore this?
nbolton
'PerlModule' is a command for mod_perl, which you say is not installed. You should find a different auth mechanism, or move your hosting to somewhere where mod_perl is available.
Ether
I believe it's the line, `PerlModule Apache2::AuthCookieDBI`. I pretty much copied the example config from: http://search.cpan.org/~matisse/Apache2-AuthCookieDBI-2.05/lib/Apache2/AuthCookieDBI.pm
nbolton
It doesn't help any to know how to install a module you have no chance of using.
brian d foy
@brian: agreed. It wasn't clear until after I wrote this answer that the problem was really that mod_perl is not installed.
Ether
+2  A: 

Apache2::AuthCookieDBI requires mod_perl, so the module isn't any use to you without it.

Greg Bacon
+2  A: 

If you are on shared hosting, you are mostly likely not using mod_perl. Thus you can't use this module. In short, mod_perl is a way for programmers to interact with apache, potentially changing how things happen. Since you are sharing apache, it's not nice to make other people live with your changes.

If you want more control over your server, you need to get a dedicated web server. How you do that depends on what your provider offers.

brian d foy
Unfortunately dedicated hosting is not an option (I do not have the authority to change this), but thanks anyway.
nbolton
Just because things are out of your control doesn't mean they aren't an option. :)
brian d foy
I do apologise for my wording blunder; what I should have said was "Unfortunately dedicated hosting is not an option for my specific situation".
nbolton