How to install php-mongo on CentOS 5.3?

I have already installed mongoDB on my VPS. It works well.

Now I want to install the php driver to get php to work with mongoDB.

I followed Mongo Installation , but I can not find the information I need. This manual contains only this notice:

If you use CentOS or Redhat, Csoke Arpad created an "RPM for these distributions ( PHP Mongo ).

I am not familiar with ssh commands on CentOS and distributions (what is it?). Can someone help me install this php extension? Please provide all ssh commands required to install it.

Thanks.

+6
php mongodb centos php-extension
source share
5 answers

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 seem to now have manual build procedures for my own deployment. Help. :)

Installing the MongoDB PHP Driver

As root:

  • export PHP_AUTOCONF = / usr / bin / autoconf
  • export PHP_AUTOHEADER = / usr / bin / autoheader
  • wget http://pecl.php.net/get/mongo-1.0.9.tgz
  • tar -xzf mongo-1.0.9.tgz
  • cd mongo-1.0.9
  • phpize
  • ./Configure
  • make && & make install
  • In /etc/php.d/mongo.ini add: extension = mongo.so
+8
source share

If you have SSH access and root, you must follow the instructions "Installing on * NIX" (RPM files are just created for convenience).

You can try using pecl ... PECL is the repository for PHP extensions, and the mongo php driver uses this system.

Here is a blog post that might help you ...

http://learnmongo.com/posts/mongodb-php-install-and-connect/

Install instructions from this post ...

Installing the command line for Linux

Through your command line, run pecl ... (if you are using sudo):

$ sudo pecl install mongo 

If you are already root ...

 # pecl install mongo 

If you get the error "Unable to find phpize , then you may need to install the PHP dev package (so you can do this, if your OS has the ability, you may need to use another method to install PHP dev packaes) ...

 $ sudo aptitude install php5-dev 

Then you will need to edit the php.ini file , add the extension mongo.so:

 extension=mongo.so 

Reboot the web server and you're done.


If pecl does not work for you, you can manually install it as described here ...

http://www.php.net/manual/en/mongo.installation.php#mongo.installation.manual

+12
source share

I just installed it on centos using:

 yum install php-pecl-mongo 

Remember to restart the server to start using it: service httpd restart

+10
source share

I installed the following http://commandperls.com/install-mongodb-php-extension/

 git clone git://github.com/mongodb/mongo-php-driver.git cd mongo-php-driver phpize ./configure make make install 

then add a new line in php.ini

extension = mongo.so

+4
source share

This worked on CeontOS 7 and PHP 7.0.0. Like other answers, but with some dependencies and a submodel update command.

 yum install cyrus-sasl cyrus-sasl-dev cd /usr/src/ git clone git://github.com/mongodb/mongo-php-driver.git cd mongo-php-driver git submodule update --init phpize ./configure make make install 

Add extension to /usr/local/lib/php.ini

 extension=mongodb.so 

Restart PHP-FPM service

 service php-fpm restart 
0
source share

All Articles