Skip to content

Instantly share code, notes, and snippets.

@jnyryan
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save jnyryan/dbcb75b114901c73b01c to your computer and use it in GitHub Desktop.

Select an option

Save jnyryan/dbcb75b114901c73b01c to your computer and use it in GitHub Desktop.
setup EC2 instance with node, nginx etc
#!/bin/sh
#################
# install prerequisites
sudo yum install -y gcc-c++ make
sudo yum install -y openssl-devel
sudo yum install -y git-core
sudo yum install -y curl
#################
# Install nginx
yum install -y nginx
touch /etc/nginx/nginx.conf
cat > /etc/nginx/nginx.conf <<EOL
location / {
proxy_pass http://127.0.0.1:1337/;
}
EOL
service nginx start
chkconfig nginx on
#########################
#Install Node.js
wget http://nodejs.org/dist/node-latest.tar.gz
tar -zxvf node-latest.tar.gz
rm -rf node-latest.tar.gz
cd node-v0.6.7
./configure --prefix=/usr
make
make install
#########################
#Install NPM
curl http://npmjs.org/install.sh | sh
#########################
# Test it
cd ~
touch hello.js
cat > hello.js <<EOL
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
EOL
node hello.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment