如何在 CentOS 5.3 上安装 php-mongo?
我已经在我的 VPS 上安装了 mongoDB。效果很好。
现在我想安装 php 驱动程序以使 php 与 mongoDB 一起工作。
我遵循 Mongo Installation 但找不到我需要的信息。本手册仅包含以下注意事项:
如果您使用 CentOS 或 Redhat,Csoke Arpad 为这些发行版创建了 » RPM ( PHP Mongo)。
我不熟悉 CentOS 和发行版上的 ssh 命令(它是什么?)。谁能帮我安装这个 php 扩展吗?请提供安装它所需的所有 ssh 命令。
谢谢。
I've already installed mongoDB on my VPS. It works well.
Now I want to install php driver to make php work with mongoDB.
I followed Mongo Installation but cannot find information I need. This manual contains only this notice:
If you are using CentOS or Redhat, Csoke Arpad created » RPMs for these distributions (PHP Mongo).
I'm not familiar with ssh commands on CentOS and distributions (what is it?). Can anyone help me install this php extension? Please provide all ssh commands needed to install it.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您有 SSH 访问权限和 root,您应该能够按照“在 *NIX 上安装”说明进行操作(RPM 只是为了方便起见而创建的。)
您可以尝试使用 pecl ... PECL 是一个PHP 扩展存储库和 mongo php 驱动程序使用该系统。
这是一篇博客文章,您可能会发现有用...
http://learnmongo。 com/posts/mongodb-php-install-and-connect/
安装该帖子中的说明 ...
Linux 命令行安装
通过命令行运行 pecl ...(如果您使用 sudo):
如果您已经是 root ...
如果您收到一条错误消息说系统找不到 phpize,那么您可能需要安装 PHP 开发包(如果您的操作系统具有 aptitude,您可能需要使用其他方法来安装 PHP 开发包)...
然后您需要编辑 php.ini 文件添加 mongo.so 扩展名:
重新启动您的网络服务器并你完成了。
如果 pecl 不适合您,您可以按照此处所述手动安装它...
If you have SSH access and root you should be able to follow the "Installing on *NIX" instructions (the RPMs are just created for convenience sake.)
You can try using pecl ... PECL is a repository for PHP Extensions and the mongo php driver uses that system.
Here is a blog post you might find helpful ...
http://learnmongo.com/posts/mongodb-php-install-and-connect/
Install instructions from that post ...
Command Line Install for Linux
Via your command line run pecl ... (if you use sudo):
If you are already root ...
If you get an error saying the system can’t find
phpize
then you may need to install the PHP dev package (this is how you do if your OS has aptitude, you might need to use some other method to install the PHP dev packaes) …You will then need to edit your php.ini file add add the mongo.so extension:
Restart your webserver and you are done.
If pecl doesn't work for you, you can manually install it as described here ...
http://www.php.net/manual/en/mongo.installation.php#mongo.installation.manual
我刚刚在centos上安装了它,使用:
不要忘记重新启动服务器来开始使用它:service httpd restart
I just installed it on centos using:
Don't forget to restart the server to start using it: service httpd restart
首先使用 pecl 尝试 Justin 的解决方案(您需要使用 yum 而不是 aptitude 来安装 php-devel),但如果这不起作用,我碰巧手头上已有手动构建过程供我自己的部署参考。 :)
安装 PHP MongoDB 驱动程序
以 root 身份:
扩展名=mongo.so
Try Justin's solution first with pecl (you'll want to use yum rather than aptitude to install php-devel), but if that doesn't work, I happen to have the manual build procedures on hand already for my own deploy reference. :)
Installing the PHP MongoDB driver
As root:
extension=mongo.so
我按照 http://commandperls.com/install-mongodb-php-extension/
然后在 php.ini 中添加新行
extension=mongo.so
I installed following the http://commandperls.com/install-mongodb-php-extension/
then add a new line in php.ini
extension=mongo.so
这适用于 CeontOS 7 和 PHP 7.0.0。与其他答案类似,但具有一些依赖项和子模型更新命令。
添加扩展到 /usr/local/lib/php.ini
重启 PHP-FPM 服务
This worked for CeontOS 7 and PHP 7.0.0. Similar to other answers but with some dependencies and submodel update command.
Add extension to /usr/local/lib/php.ini
Restart PHP-FPM service