Node.JS Installation
Installing from binary (pre-built):
Download the latest nodejs binary package (it will include npm as well) – http://nodejs.org/download/
curl -O http://nodejs.org/dist/v0.10.24/node-v0.10.24-linux-x64.tar.gz
Decompress the package and rename the directory:
tar xzf node-v0.10.24-linux-x64.tar.gz
mv node-v0.10.24-linux-x64 node
Update your PATH to reference the bin folder of the decompressed package. Example:
export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/node/bin:/opt/mongodb/bin:/home/node/opt/node/bin
Test it out!
node -v
npm -v
You should see:
[node@dbversity demo]npm -v
1.3.21
[node@dbversity demo]$ node -v
v0.10.24
Installing from source :
Here is the list of utilities and software that need to be installed on the server:
make
gcc
gcc-c++
python
bzip2
Node.js
First, logon the server and switch to the node user account.
su – node
Make sure you are in “/home/node” directory (you can use the pwd command to check where you are), and then use yum, a package manager that comes with linux, to install the following utilities/compilers:
yum install make
yum install gcc
yum install gcc-c++
Next create two new directories for the downloads and executables:
mkdir temp
mkdir opt
Swith to the temp directory:
cd temp
Use curl to being downloading the software packages into the directory:
curl http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz> python2.7.3.tgz
curl http://nodejs.org/dist/v0.10.5/node-v0.10.5.tar.gz> node0.10.5.tar.gz
curl http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz> bzip2-1.0.6.tar.gz
Decompress the files:
tar xf python2.7.3.tgz
tar xzf node0.10.5.tar.gz
tar xzf bzip2-1.0.6.tar.gz
Switch back to new bzip decompressed directory and edit the makefile using vi (a built-in editor):
cd bzip2-1.0.6
vi Makefile
Change the CSFLAG line as per below, exit the vi editor, do the make and install, and test it:
CFLAGS=-fPIC -Wall -Winline -O2 -g $(BIGFILES)
:wq (this is the command to save and exit)
make
make install PREFIX=/home/node/opt/bzip2
bzip2 -V
Switch back to the new python decompressed directory, apply configurations, do the make and install, and test it:
cd ../Python-2.7.3
export LD_LIBRARY_PATH=/home/node/opt/bzip2/lib
export LD_RUN_PATH=$LD_LIBRARY_PATH
export LDFLAGS=”-L$HOME/opt/bzip2/lib”
export CPPFLAGS=”-I$HOME/opt/bzip2/include”
export CXXFLAGS=$CPPFLAGS
export CFLAGS=$CPPFLAGS
export PATH=/home/node/opt/python/bin:$PATH
./configure –prefix=/home/node/opt/python
make
make install
python -V
Switch to the node decompressed directory, configure it, make and install it, test it:
cd ../node-v0.10.5
./configure –prefix=/opt
make
make install
node -v
Switch back to the “home” directory and configure the path as follows:
vi .bash_profile
PATH=$PATH:$HOME/bin:/opt/node/bin:/opt/mongodb/bin
export PATH
:wq (save it)
Congratulations! The Node.js install should be complete and working now.
Next step is to finish off the MongoDB configuration.
We don’t have to download anything because MongoDB was installed via the cloud dashboard console and you should have received an email confirming it’s available on the server.
Final step is to turn on the mongodb service under the root account:
su – root
service mongod start
mongo –version