The below outlines the steps taken to install node.js on a new Ubuntu installation.
Install various libraries: including git:
sudo apt-get install g++ curl libssl-dev apache2-utils git-core
Now download node.js using git:
git clone git://github.com/joyent/node.git
We are ready to install node.js; type the following:
cd node
./configure
make
sudo make install
Create a file called helloworld.js; stick the following into it:
gedit helloworld.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');
To run the hello world server:
node helloworld.js
In a browser visit:
http://127.0.0.1:8124/
To install NPM:
curl http://npmjs.org/install.sh | sudo sh
0 comments:
Post a Comment