Created
August 8, 2011 14:15
-
-
Save Kieranties/1131820 to your computer and use it in GitHub Desktop.
Installing Node on Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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! # | |
### ### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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