在Ubuntu 12.04上安装和启动用于PHP的MongoDB [英] Installing and starting MongoDB for PHP on Ubuntu 12.04

查看:132
本文介绍了在Ubuntu 12.04上安装和启动用于PHP的MongoDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从PECL安装了mongo扩展名并将其添加到我的php.ini文件中.当我运行phpinfo();时,该扩展程序会加载,但是当我尝试连接到Mongo Server时,会显示此错误.

I have installed the mongo extension from PECL and added it to my php.ini file. The extension loads when I run phpinfo(); but shows me this error when I try to connect to the Mongo Server.

Fatal error: Uncaught exception 'MongoConnectionException' with message 'Transport
endpoint is not connected' in /var/www/mongo.php:2 Stack trace: #0 /var/www/mongo.php(2):
Mongo->__construct() #1 {main} thrown in /var/www/mongo.php on line 2

phpinfo();告诉我它在localhost的默认端口上运行.

phpinfo(); tells me its running on localhost at the default port.

我还为Ubuntu安装了mongodb_client软件包,尽管我可以从终端使用 MongoLab 上的服务器,但该软件包也无法在运行的默认服务器上进行连接. PHP脚本也无法连接到 MongoLab 服务器.

Also I installed the mongodb_client package for Ubuntu, which also fails to connect on the default server running when I use it from the terminal, although it can connect to the server on MongoLab. The PHP Script also fails to connect to the MongoLab server.

在阅读了SO和其他网站上的许多问题和答案之后,我想我的计算机上的MongoDB服务器未打开.所有文章都告诉我转到可能安装MongoDB的某个文件夹,但是/var/lib/usr/lib

After reading many questions and answers on SO and other sites, I guess my MongoDB server on my computer is not turned on. All the articles tell me to go to some folder where MongoDB may be installed, but I dont have any folder in /var/lib or in /usr/lib

请帮助我使此MongoDB正常运行,我想继续从Steve Francia撰写的 MongoDB和PHP 一书中学习MongoDB.这本书没有关于安装MongoDB的很好的教程.

Please help me get this MongoDB working, I want to continue to on learn MongoDB from the MongoDB and PHP book by Steve Francia. The book doesn't have a good tutorial on installing MongoDB.

谢谢.

推荐答案

安装MongoDB(不是从软件包中进行,但可以帮助您开始使用):

Installing MongoDB (not from a package, but it'll get you started):

  • 从www.mongodb.org/downloads下载2.0.4.
  • tar zxvf mongodb-...
  • 转到刚刚解压的mongodb目录.
  • 创建一个目录来保存您的数据:

  • Download 2.0.4 from www.mongodb.org/downloads.
  • tar zxvf mongodb-...
  • Change to the mongodb directory you just untared.
  • Make a directory to hold your data:

$ mkdir myData

  • 运行:

  • Run:

    $ bin/mongod --dbpath myData
    

  • 您应该看到一些输出,然后等待端口27017上的连接",然后它将冻结"以等待您开始使用它.此时,您应该可以连接到它.

    You should see some output, then "waiting for connections on port 27017" and then it'll "freeze" waiting for you to start using it. At that point you should be able to connect to it.

    这篇关于在Ubuntu 12.04上安装和启动用于PHP的MongoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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