Skip to content

Instantly share code, notes, and snippets.

@Kieranties
Created August 8, 2011 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kieranties/1131820 to your computer and use it in GitHub Desktop.
Save Kieranties/1131820 to your computer and use it in GitHub Desktop.
Installing Node on Ubuntu
#! /bin/bash
### ###
# This script assumes you're kicking things off from a clean install of Ubuntu #
# You're welcome to skip parts which you've already installed! #
### ###
# Required - install curl
sudo apt-get install curl
# Optional - install libssl for ssl support
sudo apt-get install libssl-dev
# Get Node and build
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
# Add '--without-ssl' if not compiling with ssl support to avoid errors
./configure --prefix=~/local
make install
# Optional - install NPM (it'll make your life with node much easier!)
curl http://npmjs.org/install.sh | sh
# Optional - install Express (a great module to ease server creation)
npm install express
### ###
# That's it, go Node! #
### ###
/*
* With Node installed here's the classic Express server
*/
var app = require('express').createServer();
app.get('/', function(req, res){
res.send('Hello World');
});
app.listen(3000);
// run this with
// node express_server_sample.js
// visit http://localhost:3000 in your browser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment