node.jsのインストール
環境:Ubuntu Server LTS 10.04 32bit on VMware Player 3.1.1 (簡易インストール)
ログイン後すぐにopenssh-serverをインストールする。以降はsshで接続する。
$ sudo aptitude install openssh-server
pacoとnode.jsをダウンロードしてくる。
$ wget http://downloads.sourceforge.net/project/paco/paco/2.0.9/paco-2.0.9.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fdownloads%2Fpaco%2Fpaco%2F2.0.9%2F&ts=1283620266&use_mirror=jaist $ wget http://nodejs.org/dist/node-v0.2.0.tar.gz
aptのリポジトリがus.archive.ubuntu.comになっているのでjp.archive.ubuntu.comにする。
$ sudo vi /etc/apt/sources.list :%s/us.archive/jp.archive/g :wq $ sudo aptitude update
build-essentialをインストールする。
$ sudo aptitude install build-essential
先にpacoのインストール。アーカイブを展開、gpacoなしでインストールする。
$ tar xvfj paco-2.0.9.tar.bz2 $ cd paco-2.0.9/ $ ./configure --disable-gpaco $ make $ sudo make install $ sudo make logme
node.jsをSSLが使える状態でnode.jsをコンパイルするためlibssl-devとpkg-configをインストールする。
$ sudo aptitude install libssl-dev pkg-config
node.jsのインストール。
$ tar xvfz node-v0.2.0.tar.gz $ cd node-v0.2.0/ $ ./configure $ make $ make test $ sudo paco -D make install
node.jsの起動(example.jsは公式サイトより引用)
$ cat > example.js <<EOB > 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/'); EOB $ node example.js
他の端末、もしくはscreenからw3mを使ってページの確認をする。
$ w3m http://localhost:8124/
Hello World
参考:
Google グループ
node.js HTTPS (SSL) Server Example - Silas Sewell