Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl CGI Scripts cannot find modules in library

This is an Apache / Perl problem that I am having.

I am using a CPAN Module in my perl CGI application. It is Spreadsheet::ParseExcel

I have installed the cpan module with tar.gz files.

I have installed the dependencies.

However, I did do so as a non-root user. The library that contains these files is under a user folder, /home/user/lib

Now, I have successfully configured Apache2 on this box. The html directory is /var/www/html and the cgi folder is /var/www/html/cgi-bin. I have verified they work because all of the scripts in that folder that do not require the special modules work in my firefox browser, ie. hello world, data dumps, simple forms.

However, when I try to run the scripts that use "Spreadsheet::ParseExcel", I get the error that the module cannot be found in @INC. However, I have a "use lib" statement at the beginning of the script that adds the library.

The scripts can be run in PUTTY without problem. Only when running the script from the browser am I getting the issue.

This web application was written on another box and works fine on that box. Because I developped there of course. I put Apache2 on my personal Ubuntu machine, and installed the web application and modules here, and it works on my local box.

I have set "chmod -R a+rx" to the user library folder, so I would think that Apache has access to the folder, unless the settings of the parent directory is blocking it? I don't have to run that on the /home/user folder, or worse, the /home folder, do I?

Any insights on the issue?

Thank you all for your time!

like image 880
bleutyler Avatar asked Oct 14 '22 17:10

bleutyler


2 Answers

The Apache user cannot access /home/user/lib if it does not have access to /home/user, even if the permissions on /home/user/lib would allow it to access it.

For example, if you own a file in /root you still cannot access it if you don't have access to /root.

like image 130
carbin Avatar answered Oct 18 '22 00:10

carbin


Two thoughts here:

  1. What is the @INC it says in the error about missing modules, does it include the path you added via use lib ?
  2. Does the user that Apache runs as have access to this directory? Quite often home directories have permissions which deny traversal by other accounts. Check the permissions from the module directory all the way up, make sure o has at r-x at a minimum for all directories and files to your module.
like image 25
Tyler D Avatar answered Oct 18 '22 00:10

Tyler D