Installing MongoDB on YDL

MongoDB is a pretty good Document Database. It is NOT a Object Database. Anyway. If you want learn more about MongoDB check out this site: http://www.mongodb.org

As far as I know MongoDB is not available over the yum package manager from Yellow Dog Linux (YDL). But it is pretty easy to install. Just download the linux binaries and unpack it.

cd /opt/
sudo wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-1.8.1.tgz
sudo tar -xzf mongodb-linux-x86_64-1.8.1.tgz

For convenient reasons you can create a short symlink

sudo ln -s mongodb-linux-x86_64-1.8.1 mongodb

Now you can start all mongo binaries under “/opt/mongodb/bin”. For convenient reasons you can create more symlinks.

cd /usr/bin
sudo ln -s /opt/mongodb/bin/mongod
sudo ln -s /opt/mongodb/bin/mongo

MongoDB will save all the database stuff in the directory “/data/db”. If this directory does not exist you will get an error. Just create the directory.

sudo mkdir /data
sudo mkdir /data/db

Now you can start the MongoDB server

sudo mongod

Your MongoDB Server is up and running. In a diffrent shell you can use the mongo client to connect to the server.

mongo

Now you are in the Mongo Shell. By default the mongo client connects to the database “test”. Try this:

db.foo.save({"b":"2"})
db.foo.find()

Now you should see something like this:

{ "_id" : ObjectId("4dd975e60994b04312264239"), "b" : "2" }

Congratulation! You can exit the shell with this command:

exit

Installing Nginx 1.0.2 on Yellow Dog Linux

I just got an Yellow Dog Linux (YDL) up and running on Amazon EC2. YDL is based on Red Hat. The installation tool is called “yum”. It is similar to debians “apt-get” tool, but it is based on RPMs.

Anyway. You can install nginx via yum with this command:

sudo yum install nginx

But this is not the newest version. If you want the newest version you should install it from the source code. But at first you need to install some additional tools.

sudo yum install gcc
sudo yum install pcre
sudo yum install pcre-devel
sudo yum install zlib
sudo yum install zlib-devel
sudo yum install make

Now you can download the newest version with weget from the nginx page: http://wiki.nginx.org/Install

After the download you should unpack the *tar.gz file und navigate into the directory. Now you can install it with this 3 commands:

sudo ./configure
sudo make
sudo make install

If everything works fine it is installed here:

/usr/local/nginx/

Now you can add “/usr/local/nginx/sbin” to your PATH or you just create a symlink in “/usr/bin”

cd /usr/bin
ln -s /usr/local/nginx/sbin/nginx

For security reason you should create a nginx group.

sudo useradd -s /sbin/nologin -r nginx
sudo usermod -a -G nginx <USERNMAE>

And you should have a place where you deploy your webapps.

sudo mkdir /var/www
sudo chgrp -R nginx /var/www
sudo chmod -R 755 /var/www

Now you can start nginx with this command:

sudo nginx

And stop it with this command:

sudo nginx -s stop