Perl 和Apache HTTP 服务器:从服务器执行 cgi 脚本时无法执行 Tie MLDBM,但从命令行执行时可以。为什么?
请帮忙!我真的被这个问题搞疯了!
我有一个 CGI perl 脚本,当从 Apache HTTP 服务器执行时,它总是在以下行失败:
tie %db, 'MLDBM', "$data_path/$db_name.db", O_RDONLY, 0640 or die $!
并且错误是权限被拒绝:
软件错误:
权限在 /var/www/cgi-bin/rich/pages/display 第 381 行被拒绝。
如需帮助,请发送邮件给网站管理员 (root@localhost),提供此错误消息以及错误的时间和日期。
但是当从命令行执行时,它可以正常工作。
我已确保要绑定的目录和文件具有正确的权限。
那么我还错过了什么? Apache 的 httpd.conf 中的哪些配置可能出错?诚然,我以前没有任何使用 Apache HTTP 服务器的经验,所以这几乎是我第一次使用它。然而,我不止一次地阅读了这些手册来寻找我可能出错的地方,但我没有注意到任何事情。但我当然可能是错的。
谢谢!!
please help! I'm really going nuts with this problem!
I have a CGI perl script and it always fails at the following line when executed from the Apache HTTP server:
tie %db, 'MLDBM', "$data_path/$db_name.db", O_RDONLY, 0640 or die $!
and the error is Permission denied:
Software error:
Permission denied at /var/www/cgi-bin/rich/pages/display line 381.
For help, please send mail to the webmaster (root@localhost), giving this error message and the time and date of the error.
But when executed from the command line, it works without any problem.
I have ensured that the directories and the file to tie have the correct permissions.
So what else have I missed? What configurations in the Apache's httpd.conf I could be getting wrong? Admittedly, I didn't have any previous experience with the Apache HTTP server, so this is pretty much my first time playing around with it. However, I have read the manuals more than once to look for things I could be wrong at, but I didn't notice anything. But I could be wrong of course.
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否已验证
$data_path
和$db_name
是否包含您认为的内容?$data_path
是不依赖于活动用户身份或主目录的绝对路径吗?ls -l $data_path/$db_name.db
显示文件的所有权和权限是什么?我从来没有遇到过(或听说过)apache 中任何会阻止 CGI 进程有权打开文件的东西,所以我非常怀疑这是 apache 配置问题。最有可能的是,它正在寻找错误的文件,或者文件的权限对于 apache 运行 CGI 进程的用户来说不正确。
Have you verified that
$data_path
and$db_name
contain what you think they do?Is
$data_path
an absolute path which is not reliant on the active user's identity or home directory?What does
ls -l $data_path/$db_name.db
show for the file's ownership and permissions?I've never run across (or heard of) anything in apache that would prevent a CGI process from having permission to open files, so I highly doubt that it's an apache config issue. Most likely it's either looking for the wrong file or the file's permissions are incorrect for the user that apache is running the CGI process as.