2011-06-13 3 views
0

NoSQL 및 특히 MongoDB를 가지고 놀면서 흥미로운 점이 있습니다.서버에 MongoDB를 설치했습니다. 지금 뭐야?

sudo pecl install mongo 

몽고가 제대로 설치 것으로 보인다 내가 phpinfo()를 실행하는 경우는 '몽고'섹션 지금있다 :이를 위해, 나는 다음과 같은 명령을 서버에 SSHing를 실행하여 외부의 리눅스 박스에 MongoDB를 설치했습니다 .

하지만 지금은 무엇입니까? 나는 여기에서 생산에 사용하는 데 어려움을 겪고있는 것 같다. 문제는, MongoDB 서비스가 실행되고 있다고 생각하지 않으며, MongoDB 사용자를 구성하지 않은 이유는 확실하지 않기 때문입니다. 그 결과, 다음과 같은 테스트 스크립트가 실패 :

<?php 

// connect 
$m = new Mongo(); 

// select a database 
$db = $m->comedy; 

// select a collection (analogous to a relational database's table) 
$collection = $db->cartoons; 

// add a record 
$obj = array("title" => "Calvin and Hobbes", "author" => "Bill Watterson"); 
$collection->insert($obj); 

// add another record, with a different "shape" 
$obj = array("title" => "XKCD", "online" => true); 
$collection->insert($obj); 

// find everything in the collection 
$cursor = $collection->find(); 

// iterate through the results 
foreach ($cursor as $obj) { 
    echo $obj["title"] . "\n"; 
} 

?> 

나는 다음과 같은 오류 메시지가 얻을으로 :

Fatal error: Uncaught exception 'MongoConnectionException' with message 'connecting to failed: Transport endpoint is not connected' in /home/[username]/public_html/mongodbtest/index.php:4 Stack trace: #0 /home/[username]/public_html/mongodbtest/index.php(4): Mongo->__construct() #1 {main} thrown in /home/woohoobi/public_html/mongodbtest/index.php on line 4

가 어떻게하여 MongoDB를 사용하여 여기에서 얻을 수 있습니까?

답변

1

MongoDB를 실제로 설치 한 것이 아니라 MongoDB 인스턴스에 연결할 수있는 PHP 확장을 설치했습니다. downloading it으로 MongoDB를 설치하고 서버에 설치 한 다음 PHP 스크립트에서 MongoDB에 연결하십시오.

+0

감사합니다. 나는 curl을 실행했다. http://downloads.mongodb.org/linux/mongodb-linux-x86_64-1.8.1.tgz> mongo.tgz' - [this] (http://i.imgur.com/QmJuW. png) 일어날 예정입니까? o_O –

+0

괜찮습니다. 이제 파일을 압축 해제합니다 ('tar zxf'). 거기에서 설치하십시오. 또는'apt' 또는'yum'에서 설치할 수도 있습니다. –

+0

나는 모두 기동 중이다! 다시 한번 감사드립니다. 이 페이지의 지침을 따랐습니다. http://www.mongodb.org/display/DOCS/Quickstart+Unix –