Ubuntu DesktopにNode.jsをインストール
基本的に以下のインストラクションに沿って実行。
https://github.com/joyent/node/wiki/Installation
はじめにgitがインストールされているか確認。
$ git --version
とやると、インストールされていなければ、
プログラム 'git' はまだインストールされていません。 次のように入力することでインストールできます:
sudo apt-get install git
と教えてくれる。
$ sudo apt-get install git
つぎに
$ git clone --depth 1 https://github.com/joyent/node.git
とやってnode.jsのダウンロード開始。
nodeというディレクトリができるので
$ cd node
$ mkdir ~/local
$ ./configure --prefix=$HOME/local/node
とやるとOpenSSL関係のパッケージが無いと起こられる
/home/nabe/node/wscript:307: error: Could not autodetect OpenSSL support. Make sure OpenSSL development packages are installed. Use configure --without-ssl to disable this message.
なのでパッケージマネージャーよりlibssl-devをインストールし、再び
$ ./configure --prefix=$HOME/local/node
こんどは成功!
$ make
$ make install
$ export PATH=$HOME/local/node/bin:$PATH
さらに.profileにも
export PATH=$HOME/local/node/bin:$PATH
を追加。
つづいて
http://nodejs.jp/nodejs.org_ja/api/synopsis.html
の概要に書いてあるサンプルコードを入力
$ nano -w example.js
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8080);
console.log('Server running at http://localhost:8080/');