【发布时间】:2012-10-15 07:41:57
【问题描述】:
我遇到了奇怪的问题。,
从命令行 cgi bash 脚本和 cgi perl 脚本正在运行,但从浏览器中只有 cgi bash 脚本正在运行,而不是 cgi perl。
从浏览器访问 cgi perl 脚本后,我得到 500 Internal server error。
and apache error log says
[Thu Oct 25 01:58:59 2012] [error] [client x.x.x.x] (13)Permission denied: exec of '/home/x/x/x/x/public_html/cgi-bin/test.cgi' failed
[Thu Oct 25 01:58:59 2012] [error] [client x.x.x.x] Premature end of script headers: test.cgi
我想从浏览器运行 cgi perl 脚本。
我该怎么做。
[root@www ~]# which perl
/usr/bin/perl
[root@www cgi-bin]# perl test.cgi
Content-type: text/plain
testing...
test.cgi 的来源
#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print "testing...\n";
感谢您的宝贵时间。
它是一个带有 apache 2 的专用服务器。
【问题讨论】:
-
确保 Web 服务器的用户 ID 对
test.cgi路径中的所有内容具有读取和执行权限。 -
试试
su www-data(或任何apache的用户),然后运行脚本,看看它是否有效。 -
su apache 无法正常工作,因此我将 httpd.conf 中的用户和组更改为 cgi 文件的所有者,瞧,一切正常。非常感谢,现在我如何为用户 apache 添加权限访问 .cgi 文件
-
现在我修改了 passwd 并为用户 apache 提供了一个 shell,我尝试了 su apache 它工作,然后我尝试执行它说“bash:/usr/bin/perl:权限被拒绝”的脚本,谢谢跨度>