CGI Perl脚本不工作,只有CGI的bash脚本正在努力? [英] cgi perl scripts not working, only cgi bash scripts are working?

查看:176
本文介绍了CGI Perl脚本不工作,只有CGI的bash脚本正在努力?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有奇怪的问题。

命令行CGI的bash脚本和CGI Perl脚本正在,但从浏览器只CGI的bash脚本正在努力,而不是CGI perl的

从浏览器访问CGI Perl脚本后,我得到的 500内部服务器错误

after accessing cgi perl scripts from browser i get 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脚本。

i want to run cgi perl scripts from browser .

我如何做到这一点。

[root@www ~]# which perl
/usr/bin/perl

[root@www cgi-bin]# perl test.cgi
Content-type: text/plain

testing...

test.cgi源

source of test.cgi

#!/usr/bin/perl

print "Content-type: text/plain\n\n";
print "testing...\n";

感谢您的时间。

它是一个专用的服务器和Apache 2。

its a dedicated server with apache 2.

推荐答案

检查哪些用户是通过

[root@www ~]# top | grep httpd
15607 apache    16   0  210m  19m 4228 S 23.5  0.2   0:00.52 httpd

在apache用户之上运行。

in above the apache user is running.

尝试苏阿帕奇,

确认您是通过使用命令WHOAMI了Apache,

confirm you are apache by using command whoami ,

如果您还没有切换到阿帕奇那么这意味着没有外壳被分配给用户的Apache,

if you havent switched to apache then this means no shell is assigned to user apache,

现在修改/ etc / passwd文件

now modify /etc/passwd file

查找用户Apache和更改结束

find user apache and change ending from

/bin/false

to 

/bin/bash

保存passwd文件中,然后尝试苏阿帕奇,与WHOAMI检查,
如果成功切换到用户阿帕奇然后转到该脚本所在的目录,并尝试从那里运行它。

save passwd file , then try su apache, check with whoami, if you successfully switched to user apache then go to the directory where the script is located and try to run it from there.

您会得到类似

bash: /usr/bin/perl: Permission denied

这意味着用户阿帕奇没有权限用户的Perl。

this means user "apache" does not have permissions to user perl.

您需要添加的权限来执行perl脚本用户阿帕奇。

you need to add permissions to execute perl script to user "apache".

***不要忘记更改passwd文件,因为它是previously。

***dont forget to change the passwd file as it was previously.

您可以通过添加一组特定的用户和不断变化的组名httpd.conf中做到这一点。

you can do that by adding a group to specific user and changing the group name httpd.conf.

感谢

这篇关于CGI Perl脚本不工作,只有CGI的bash脚本正在努力?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆