How To Install MongoDB on CentOS 6.X or WHM Server

Installing MongoDB via MongoDB Repo

MongoDB has its own Repo. There are a bunch of great Repo’s out there, such as the Atomicorp Repo (gotroot) that may include MongoDB, but in this case we are going to add the official repo and use that to install it

1. On a CentOS server enter

cd /etc/yum.repos.d

– other systems such as Ubuntu and Debian have a similar folder where repos are stored

2. Now let’s create a new file called mongodb.repo

pico mongodb.repo

3. Copy and paste this code:

[mongodb]
name=MongoDB Repo
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1

4. Hit CTRL + O to write the file, then CTRL + X to exit

5. Now let’s use yum to install MongoDB via

yum install mongo-10gen mongo-10gen-server

6. We’re done – if you ran into any dependencies, you need to google them or post a comment below.

7. Make sure you add the MongoDB service to your config, so it will be automatically started when you reboot your server:

chkconfig mongod on

8. Start the service with

service mongod start

Next Step: Installing The MongoDB PHP Extension

We’re not done yet. To properly use MongoDB we also need a PHP extension. What we installed above is only the service. Luckily, this PHP package is up to date and we CAN use pecl to quickly install this viahttp://pecl.php.net/package/mongo

1. Enter

pecl install mongo

if pecl not installed

install it first

 yum install php-pear php5-dev
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s