Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl 访问CGI程序中的Hypertable时权限被拒绝_Perl_Apache_Cgi_Thrift_Hypertable - Fatal编程技术网

Perl 访问CGI程序中的Hypertable时权限被拒绝

Perl 访问CGI程序中的Hypertable时权限被拒绝,perl,apache,cgi,thrift,hypertable,Perl,Apache,Cgi,Thrift,Hypertable,我正在尝试使用Perl开发一个Web应用程序。示例代码: #!/usr/bin/perl -w use strict; use warnings; use CGI; use CGI::Carp qw/fatalsToBrowser warningsToBrowser/; use CGI::Session ('-ip_match'); use Hypertable::ThriftClient; use Data::Dumper; my $q = new CGI; print $q->hea

我正在尝试使用Perl开发一个Web应用程序。示例代码:

#!/usr/bin/perl -w
use strict;
use warnings;
use CGI;
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
use CGI::Session ('-ip_match');
use Hypertable::ThriftClient;
use Data::Dumper;

my $q = new CGI;
print $q->header(-cache_control => "no-cache, no-store, must-revalidate");

eval {
    my $client    = new Hypertable::ThriftClient("localhost", 38080);
    my $namespace = $client->open_namespace("glinpe");
    my $result    = $client->hql_exec($namespace, "select * from words where row=\"maths\" keys_only");
};

if ($@) {
    if ($@->isa('Thrift::TException')) {
        print Dumper($@);
    } else {
        print Dumper($@);
    }
}
print "<h1>works</h1>";
当从终端(在apache用户下)运行脚本时,脚本可以正常工作,如果删除所有超表格代码,脚本也可以在浏览器中正常工作

我已在iptables中打开38080端口:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 38080 -j ACCEPT

OS:Centos 5.6。

错误消息说您缺少权限,因此这就是答案(用户apache没有创建本地主机套接字的权限:38080)

更新:更详细地说,当您从终端运行它时,它是作为普通用户运行的,但当apache运行它时,它通常是在apache用户帐户下运行的,该帐户可能没有打开套接字的权限

可能是你在使用SELinux,在这种情况下,请参见“man chcon”
或者搜索“SELinux教程:配置RHEL 5和Web服务器”

好的,因此有两种解决方案来解决这个特定问题: 1.禁用selinux-在/etc/selinux/config中更改配置 2.运行命令:

setsebool-p httpd_can_网络_连接1


感谢前面的回答让我回到正轨。

我已经尝试手动切换到apache用户并再次在终端中运行脚本。它仍然可以工作(但不是通过浏览器)。我已经在iptables中打开了所需的端口。
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 38080 -j ACCEPT