简体   繁体   English

Perl CGI Scripts在库中找不到模块

[英]Perl CGI Scripts cannot find modules in library

This is an Apache / Perl problem that I am having. 这是我遇到的Apache / Perl问题。

I am using a CPAN Module in my perl CGI application. 我在perl CGI应用程序中使用CPAN模块。 It is Spreadsheet::ParseExcel 它是Spreadsheet :: ParseExcel

I have installed the cpan module with tar.gz files. 我已经用tar.gz文件安装了cpan模块。

I have installed the dependencies. 我已经安装了依赖项。

However, I did do so as a non-root user. 但是,我确实以非root用户身份执行了此操作。 The library that contains these files is under a user folder, /home/user/lib 包含这些文件的库位于用户文件夹/ home / user / lib下

Now, I have successfully configured Apache2 on this box. 现在,我已在此框中成功配置了Apache2。 The html directory is /var/www/html and the cgi folder is /var/www/html/cgi-bin. html目录是/ var / www / html,cgi文件夹是/ 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. 我已经验证它们有效,因为该文件夹中不需要特殊模块的所有脚本都在我的firefox浏览器中工作,即。 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. 但是,当我尝试运行使用“Spreadsheet :: ParseExcel”的脚本时,我得到的错误是在@INC中找不到该模块。 However, I have a "use lib" statement at the beginning of the script that adds the library. 但是,我在添加库的脚本开头有一个“use lib”语句。

The scripts can be run in PUTTY without problem. 脚本可以在PUTTY中运行而不会出现问题。 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. 这个Web应用程序写在另一个盒子上,并在该盒子上正常工作。 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. 我将Apache2放在我的个人Ubuntu机器上,并在这里安装了Web应用程序和模块,它可以在我的本地机器上运行。

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? 我已经将“chmod -R a + rx”设置为用户库文件夹,所以我认为Apache可以访问该文件夹,除非父目录的设置阻止了它? I don't have to run that on the /home/user folder, or worse, the /home folder, do I? 我不必在/ home / user文件夹上运行它,或者更糟的是/ home文件夹,是吗?

Any insights on the issue? 有关这个问题的任何见解?

Thank you all for your time! 谢谢大家的时间!

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. 如果Apache用户无法访问/ home / user,则无法访问/ home / user / lib,即使/ home / user / lib上的权限允许它访问它。

For example, if you own a file in /root you still cannot access it if you don't have access to /root. 例如,如果您拥有/ root中的文件,则如果您无权访问/ root,则仍无法访问该文件。

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 ? 它在关于缺少模块的错误中说的@INC是什么,它是否包含你通过use lib添加的路径?
  2. Does the user that Apache runs as have access to this directory? Apache运行的用户是否可以访问此目录? 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 rx at a minimum for all directories and files to your module. 从模块目录一直检查权限,确保o至少对于模块的所有目录和文件至少为rx。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM