Perl CGI 脚本无法在库中找到模块
这是我遇到的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果 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.
这里有两个想法:
use lib
添加的路径?Two thoughts here:
use lib
?