Skip to content

Instantly share code, notes, and snippets.

@dstroot
Created March 25, 2012 01:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dstroot/2190579 to your computer and use it in GitHub Desktop.
Save dstroot/2190579 to your computer and use it in GitHub Desktop.
An EC2 setup script to install Node.js
#!/bin/bash
echo "*****************************************"
echo " get superuser and install all updates "
echo "*****************************************"
sudo su
yum –y update
echo "*****************************************"
echo " Installing Development Tools"
echo "*****************************************"
yum install gcc gcc-c++ make -y
yum install openssl-devel -y
yum install git -y
echo "*****************************************"
echo " Installing Node.js"
echo "*****************************************"
echo " You can’t just use yum – you actually have to"
echo " compile Node.js. You can view all available"
echo " Node tags (versions) by typing ‘git tag –l’."
echo " The make command will take a while to complete"
echo " (30+ minutes), so have a coffee..."
echo "*****************************************"
cd /usr/local/src
git clone git://github.com/joyent/node.git
cd node
git checkout v0.6.17
export JOBS=2
./configure
make
make install
echo "*****************************************"
echo " NodeJS modules can now be installed via npm"
echo " add any global modules to the list below"
echo "*****************************************"
# https://github.com/nodejitsu/forever
# https://github.com/creationix/step
npm install forever step hiredis redis -g
echo "*****************************************"
echo " When complete, NodeJS will be installed to"
echo " /usr/local/bin/node. If desired, it can be"
echo " added to your path (environment variable)."
echo " We will now edit /etc/sudoers! When nano starts"
echo " find and edit the line ‘Defaults secure_path...’"
echo " and add “:/usr/local/bin” to the end of the path"
echo "*****************************************"
read -p "Press [Enter] to continue..."
nano /etc/sudoers
echo "*****************************************"
echo " Now we will rediect port 80 traffic to"
echo " the port Node.js will be listening on."
echo " Standard practices say no non-root process"
echo " gets to talk to the Internet on a port less"
echo " than 1024. Proxying through nginx or Apache"
echo " uses additional resources. Do not run node"
echo " as root or ec2-user - you have been warned."
echo "*****************************************"
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment