Web Projects Outsourcing

Setting Up MongoDB on Fedora with Basic Security Options

MongoDB is a popular NoSQL database solution with growing popularity over professional and non-professional users. Blah. Now to setting all up.

MongoDB in Fedora repo will not work with authentication and segfault, get it and install from MongoDB site.

Cut and paste the below:

[text gutter=”false”]
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
[/text]

Install MongoDB:

Edit the default config file.

Find and edit:

[text gutter=”false”]
bind_ip = 127.0.0.1
port = 27017
dbpath=/var/lib/mongo
[/text]

Create a very basic service:

Cut and paste:

[text]
#! /bin/sh

chkconfig: 345 20 80

description: mongod daemon

processname: mongod

N=/usr/bin/mongod

set -e

case "$1" in
start)
$N -f /etc/mongod.conf –journal
;;
stop|reload|restart|force-reload)
;;
*)
echo "Usage: $N {start|stop|restart|force-reload}" >&2exit 1
;;
esac

exit 0
[/text]

Run service:

Check if all ok:

Or visit in browser: http://localhost:28017 (we are going to close that later).

You can stop the above service from mongo console:

Add possibility for PHP to connect to it and restart web server:

Test:

Add more security:

Edit the config again:

Find and edit:

[text gutter=”false”]
noauth = false
auth = true
nohttpinterface = true
[/text]

Stop and start the server again as described above.

Get and install some web admin tool into a folder on your web server, for instance http://code.google.com/p/rock-php/wiki/rock_mongo. To connect, edit the config.php file from this package with the following values:

DISCLAIMER: tested for Fedora 15 only and might require more security fixes.

RockMongo with auth in Fedora 15

Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *

3 × 5 =