Skip to content

Instantly share code, notes, and snippets.

@billyriantono
Last active August 29, 2015 14:05
Show Gist options
  • Save billyriantono/d83b8b5539c371f2424e to your computer and use it in GitHub Desktop.
Save billyriantono/d83b8b5539c371f2424e to your computer and use it in GitHub Desktop.
Automatic Installing NodeJS in your Linux Machine
#!/usr/bin/env bash
#
# Install Automatically Node JS v 0.10
# by Billy Riantono - billy[ at ]riantono.com
# Variables
NODE_INSTALL_DIR='/opt/nodejs/'
NODE_DOWNLOAD_URL='http://nodejs.org/dist/v0.10.31/node-v0.10.31-linux-x64.tar.gz'
#function
ok() { echo -e '\e[32m'$1'\e[m'; } # Green
# Sanity check
[ $(id -g) != "0" ] && die "Script must be run as root."
#Download Node
if [ ! -f /usr/bin/unzip ]; then
yum -y -q install unzip
fi
mkdir $NODE_INSTALL_DIR;
cd $NODE_INSTALL_DIR
wget $NODE_DOWNLOAD_URL
tar zxvf node-v0.10.31-linux-x64.tar.gz
mv node-v0.10.31-linux-x64/* ./
rm -rf node-v0.10.31-linux-x64
rm -rf node-v0.10.31-linux-x64.tar.gz
#adding path to environment
export PATH=$PATH:/opt/nodejs/bin
ok "Install Node Success, you can try run with type node in your console";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment