我正在嘗試使用Hypertable在Perl中開發Web應用程序。示例代碼:在訪問CGI程序中的Hypertable時拒絕訪問
#!/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 ([email protected]) {
if ([email protected]>isa('Thrift::TException')) {
print Dumper([email protected]);
} else {
print Dumper([email protected]);
}
}
print "<h1>works</h1>";
試圖從Web瀏覽器執行,我得到一個錯誤,當問題是:從終端運行時
$VAR1 = bless({ 'code' => 0, 'message' => 'TSocket: Could not connect to localhost:38080 (Permission denied)' }, 'Thrift::TException');
腳本正常工作(下apache用戶),和如果刪除所有Hypertable代碼,那麼在瀏覽器中。
我已經38080端口iptables中打開:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 38080 -j ACCEPT
OS:Centos的5.6。
我已經嘗試手動切換到apache用戶並再次在終端中運行腳本。它仍然有效(但不是來自瀏覽器)。我在iptables中打開了需要的端口。 – 2011-06-12 23:59:15