2012-01-08 132 views
2

我儘量按照這個PHP開發人員介紹了比特幣https://en.bitcoin.it/wiki/PHP_developer_introJSON-RPC PHP無法連接到本地服務器bitcoind

我讓虛擬專用服務器上,此步驟,一切工作正常。但是,當我試圖與操作系統Fedora 14的我的虛擬機上執行相同的步驟,從文章的例子給我一個錯誤:

Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to http://user:[email protected]:8332/' in /var/www/html/jsonRPCClient.php:140 
Stack trace: 
#0 /var/www/html/btc.php(7): jsonRPCClient->__call('getbalance', Array) 
#1 /var/www/html/btc.php(7): jsonRPCClient->getbalance() 
#2 {main} 
    thrown in /var/www/html/jsonRPCClient.php on line 140 

代碼:

<?php 
require_once 'jsonRPCClient.php'; 

$bitcoin = new jsonRPCClient('http://user:[email protected]:8332/'); 

echo "<pre>\n"; 
print_r($bitcoin->getbalance()); 
echo "</pre>"; 
?> 

當我執行。/bitcoind getbalance或命令行中的./bitcoind getinfo,我得到答案, ,但PHP腳本不起作用。

netstat的給了我下面的:

[[email protected] 32]# netstat -tap 
Active Internet connections (servers and established) 
Proto Recv-Q Send-Q Local Address    Foreign Address    State  PID/Program name 
tcp  0  0 *:mysql      *:*       LISTEN  1297/mysqld   
tcp  0  0 localhost.localdomain:8332 *:*       LISTEN  2171/bitcoind  
tcp  0  0 *:8333      *:*       LISTEN  2171/bitcoind  
tcp  0  0 localhost.localdomain:ipp *:*       LISTEN  1000/cupsd   
tcp  0  0 localhost.localdomain:smtp *:*       LISTEN  1337/sendmail: acce 
tcp  0  0 vitaly:39994    irc.lfnet.org:ircu-3  ESTABLISHED 2171/bitcoind  
tcp  0  0 vitaly:50594    c-98-207-155-236.hsd1.:8333 ESTABLISHED 2171/bitcoind  
tcp  0  0 vitaly:57654    c-67-170-81-79.hsd1.wa:8333 ESTABLISHED 2171/bitcoind  
tcp  0  0 localhost.localdomain:40427 localhost.localdomain:http TIME_WAIT -     
tcp  0  0 vitaly:57486    ip72-193-65-74.lv.lv.c:8333 ESTABLISHED 2171/bitcoind  
tcp  0  0 vitaly:56222    109.254.91.55:8333   ESTABLISHED 2171/bitcoind  
tcp  1  0 vitaly:47205    stackoverflow.com:http  CLOSE_WAIT 2016/firefox   
tcp  0  0 vitaly:59602    pool-108-20-235-196.bs:8333 ESTABLISHED 2171/bitcoind  
tcp  0  0 vitaly:33671    bk-in-f102.1e100.net:https ESTABLISHED 2016/firefox   
tcp  0  0 vitaly:46155    host86-144-29-61.range:8333 ESTABLISHED 2171/bitcoind  
tcp  0  0 vitaly:45357    cpe-098-026-012-202.nc:8333 ESTABLISHED 2171/bitcoind  
tcp  0  0 *:http      *:*       LISTEN  1370/httpd   
tcp  0  0 vitaly:ipp     *:*       LISTEN  1000/cupsd 

bitcion.conf:

rpcuser=user 
rpcpassword=123456 

rpcport=8332 

我應該怎麼檢查?

+2

檢查SELinux的。對於測試,請停止selinux,然後嘗試 – 2012-01-08 09:59:02

+0

非常感謝!這有助於 – user1136881 2012-01-08 10:34:54

回答

0

檢查您是否通過HTTPS連接而不是HTTP,如果你的服務器是建立由證書而不是密碼進行身份驗證。

1

請務必讓你的服務器IP(如PHP的一部分位於!)

rpcuser=user 
    rpcpassword=123456 
    rpcport=8332 
    rpcallowip=192.168.0.123 (server php ip) 

我忘了,每次做的,運行PHP給我連接錯誤或空白各一次。 :/

+0

4年已經過去,因爲我張貼的問題:d – user1136881 2017-01-27 05:59:26

+0

有一個正確的答案不正確的時間:d – btc4cash 2017-01-30 00:05:41

相關問題