https://www.learn2crack.com/2014/04/setup-node-js-and-mongodb.html
ode.js and MongoDB are hot technologies available today used in various real time applications. In this tutorial we are going to Setup Node.js platform and MongoDB database in Ubuntu and Windows. We will be using these technologies with our Android projects later.
Ubuntu users can easily install Node.js from the repository using the command in terminal.
sudo apt-get install nodejs
-> Install the dependencies.
sudo apt-get install g++ curl libssl-dev apache2-utils
-> Download node JS sources from http://nodejs.org/dist/v0.10.26/node-v0.10.26.tar.gz
-> Extract the downloaded sources.
-> Then switch to the extracted directory via terminal.
-> Then enter the following commands.
./configure sudo make sudo make install
Now Node.js will now be installed in your Ubuntu machine.
To test enter the command in the terminal which shows the Node.js version.
node -v
Installing Node.js in Windows is as easy as eating a piece of cake.
->Just download the windows installer from the link and install as typical windows installation.
64 bit -> http://nodejs.org/dist/v0.10.26/x64/node-v0.10.26-x64.msi
32 bit -> http://nodejs.org/dist/v0.10.26/node-v0.10.26-x86.msi
->To test open the command prompt and run the command to see the version of Node.js installed.
node -v
Testing Hello World
Open a text document and enter the following code and save it as hello.js
var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World !'); }).listen(8080, '127.0.0.1'); console.log('Server running at http://127.0.0.1:8080/');
Now open the terminal or command prompt and run it as
node hello.js
Now Node.js will be running in the port 8080 in localhost. Open your browser and verify it.
To setup MongoDB in Ubuntu open the terminal and enter the following commands.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB1
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install mongodb-org
Now MongoDB will be installed in your Ubuntu Machine.
Start MongoDB by using the command
sudo service mongod start
Stop MongoDB by using the command
sudo service mongod stop
-> Download MongoDB for windows from the link and install as typical windows installation.
64 bit -> https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-2.6.0.msi
32 bit -> https://fastdl.mongodb.org/win32/mongodb-win32-i386-2.6.0.msi
-> After installation create a directory for database elsewhere (ie c:data)
After installation switch to the installation folder. Open Command prompt.
Run the command
mongod --dbpath c:data
Now MongoDB will be running in your Windows Machine.
Robomongo is a GUI client to access and work with MongoDB database. It is available for all three platforms. Download and install MongoDB for your required platform from the website http://robomongo.org/.
Any questions comment here