painthappy has asked for the wisdom of the Perl Monks concerning the following question:

Sounds crazy, but I just can't get it to work. I know I'm missing something, but I'm tossing up my hands in frustration!

I wrote a custom module to run with my site. The .pm works and runs fine in the cgi-bin next to a test.cgi file. Great. But if I take the .pm and .cgi out of the cgi-bin, and put it into the httpdocs folder and run my test.cgi, I get an internal server error.

I know it's not the code, as it runs fine from the browser in the cgi-bin.

In the httpdocs folder, via ssh, I can run the test.cgi file and it will run fine, but that is via command line and as root.

So... My question is: What permissions and I royally missing?

On a side note: I've changed everything I could think of in the httpd.conf file, and the .cgi runs fine MINUS the .pm, so it's the .pm file that is causing the issue

Thanks in advance, and thank you from saving me from this!!!

  • Comment on Run a custom module outside of the cgi-bin

Replies are listed 'Best First'.
Re: Run a custom module outside of the cgi-bin
by Herkum (Parson) on Jan 21, 2007 at 01:48 UTC

    If you have not installed the module in a location that Perl can find it, the module will not be loaded. If you are not installing it in the shared site lib directory you can add the use lib to look for the module in another location.

    #!/usr/bin/perl # You install Foo::Bar at /home/painthappy/perl/lib/Foo/Bar.pm use lib '/home/painthappy/perl/lib'; use Foo::Bar;
      Ah.. nice.. the use lib worked! Thank you. I thought I was fine with just using: require "/home/my/directory/vTest.pm"; And that seemed to work, but I've been shown that isn't the correct way. Great! Thank you so much!
Re: Run a custom module outside of the cgi-bin
by Joost (Canon) on Jan 21, 2007 at 01:40 UTC
      Ok... But it doesn't seem to be too helpful
      [ ERROR MESSAGE FROM LOG ] [Sat Jan 20 19:44:12 2007] [error] Can't locate vTest.pm in @INC (@INC + contains: /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl +5/5.8.5 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/l +ib/perl5/site_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/site_ +perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2/i38 +6-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread +-multi /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/li +b/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5 +/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_p +erl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /us +r/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/ +vendor_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/ +5.8.3/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.2/i386-l +inux-thread-multi /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread- +multi /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/l +ib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/lib/ +perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2 /usr/lib/per +l5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/ +vendor_perl . /etc/httpd/ /etc/httpd/lib/perl) at /var/www/vhosts/myw +ebpage.com/httpdocs/test.cgi line 33.\nBEGIN failed--compilation abor +ted at /var/www/vhosts/mywebpage.com/httpdocs/test.cgi line 33.\n [ END MESSAGE FROM LOG ]
      Again... I just run the module locally...

      If I put the test.cgi and the vTest.pm in the cgi-bin... no problem. nicely run. If I put both in my httpdocs folder... and do the same. Nothing. Just this above error. But the file is there and with the same permissions. Nothing has changed.

      Hence why I'm stumped.

Re: Run a custom module outside of the cgi-bin
by f00li5h (Chaplain) on Jan 21, 2007 at 11:20 UTC

    Cpan as non root makes mention of tricks to install things with cpan, at the end it mentions PERL5LIB and PERLLIB environment variables ... whih are added to the @INC

    so an entry in a .htaccess for apache like SetEnv PERL5LIB /home/f00li5h/my_random_perl_modules will cause perl to look there too.

    @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;