1

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?

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Nick Bolton
  • 38,276
  • 70
  • 174
  • 242

4 Answers4

2

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

Greg Bacon
  • 134,834
  • 32
  • 188
  • 245
2

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
  • 129,424
  • 31
  • 207
  • 592
  • Unfortunately dedicated hosting is not an option (I do not have the authority to change this), but thanks anyway. – Nick Bolton Jan 09 '10 at 17:50
  • Just because things are out of your control doesn't mean they aren't an option. :) – brian d foy Jan 09 '10 at 18:07
  • I do apologise for my wording blunder; what I should have said was "Unfortunately dedicated hosting is not an option for my specific situation". – Nick Bolton Jan 09 '10 at 18:23
0

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".

Community
  • 1
  • 1
Ether
  • 53,118
  • 13
  • 86
  • 159
  • The sever has `cpan`, but I am not root. – Nick Bolton Jan 09 '10 at 17:45
  • 1
    @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 Jan 09 '10 at 17:52
  • What about the "Invalid command 'PerlModule'" error? Should I ignore this? – Nick Bolton Jan 09 '10 at 17:55
  • 1
    '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 Jan 09 '10 at 17:56
  • 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 – Nick Bolton Jan 09 '10 at 18:00
  • It doesn't help any to know how to install a module you have no chance of using. – brian d foy Jan 09 '10 at 18:17
  • @brian: agreed. It wasn't clear until after I wrote this answer that the problem was really that mod_perl is not installed. – Ether Jan 09 '10 at 18:25
-2

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
  • 161,544
  • 178
  • 535
  • 806
  • 1
    Manual installation of modules should only be done in unusual circumstances. – Ether Jan 09 '10 at 17:27
  • 1
    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. – Nick Bolton Jan 11 '10 at 15:29
  • 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 Jan 14 '10 at 19:13
  • One reason for that: being able to move your code to another server. Also "path" could contain a ".." inside. – sorin Jan 15 '10 at 02:53