Perl CGI 脚本无法在库中找到模块

发布于 2024-10-14 10:36:48 字数 800 浏览 6 评论 0原文

这是我遇到的 Apache / Perl 问题。

我在我的 Perl CGI 应用程序中使用 CPAN 模块。它是 Spreadsheet::ParseExcel

我已经使用 tar.gz 文件安装了 cpan 模块。

我已经安装了依赖项。

然而,我是以非 root 用户的身份这样做的。包含这些文件的库位于用户文件夹 /home/user/lib

下 现在,我已在此机器上成功配置了 Apache2。 html 目录是/var/www/html,cgi 文件夹是/var/www/html/cgi-bin。我已经验证它们可以工作,因为该文件夹中不需要特殊模块的所有脚本都可以在我的 Firefox 浏览器中工作,即。你好世界,数据转储,简单的表格。

但是,当我尝试运行使用“Spreadsheet::ParseExcel”的脚本时,出现在@INC 中找不到该模块的错误。但是,我在添加库的脚本开头有一个“use lib”语句。

这些脚本可以在 PUTTY 中运行,没有问题。仅当从浏览器运行脚本时我才会遇到问题。

该 Web 应用程序是在另一个盒子上编写的,并且在该盒子上运行良好。当然因为我在那里发展。我将 Apache2 放在我的个人 Ubuntu 机器上,并在此处安装了 Web 应用程序和模块,它可以在我的本地机器上运行。

我已将“chmod -R a+rx”设置为用户库文件夹,所以我认为Apache可以访问该文件夹,除非父目录的设置阻止了它?我不必在 /home/user 文件夹上运行它,或者更糟糕的是,在 /home 文件夹上运行它,是吗?

对这个问题有什么见解吗?

感谢大家抽出宝贵的时间!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

×眷恋的温暖 2024-10-21 10:36:48

如果 Apache 用户无权访问 /home/user,则无法访问 /home/user/lib,即使 /home/user/lib 上的权限允许其访问。

例如,如果您在 /root 中拥有一个文件,那么如果您无权访问 /root,您仍然无法访问它。

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.

遗心遗梦遗幸福 2024-10-21 10:36:48

这里有两个想法:

  1. 关于丢失模块的错误中所说的 @INC 是什么,它是否包含您通过 use lib 添加的路径?
  2. Apache 运行的用户是否有权访问该目录?通常主目录具有拒绝其他帐户遍历的权限。检查模块目录的权限,确保模块的所有目录和文件至少具有 rx 权限。

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文