ServersManのCentOS release 5.5にnode.jsをインストール
node.jsをServersMan EntryプランのCentOS5.5にインストールしたときの記録。
まずはソースコードをダウンロードし、展開。
# su - # cd /usr/local/src # wget http://nodejs.org/dist/node-v0.2.3.tar.gz # tar xzvf node-v0.2.3.tar.gz # cd node-v0.2.3
configure。prefixのみ指定。
※削除やバージョン管理がしやすいので、自分はよくこういうprefixを指定します。rpmとかdebにするのはめんどくさいし…
# ./configure --prefix=/usr/local/node-v0.2.3
ここでエラー。
Checking for program g++ or c++ : not found Checking for program icpc : not found Checking for program c++ : not found /usr/local/src/node-v0.2.3/wscript:132: error: could not configure a cxx compiler!
C++のコンパイラが足りないようなので、yumでインストール。
yum update yum install gcc-c++
再度configure後、色々not foundと表示されているが、とりあえず成功したようなので、make⇒make install。
# make # make install
シンボリックリンクを張っておく。
※バージョンアップしたときのpathや起動スクリプトのメンテ性から、自分はよくこうします。
# /usr/local # ln -s node-v0.2.3 node-js # exit
ユーザーのパスに追加。
$ cd ~ $ vim .bash_profile PATHの定義部分を PATH=$PATH:$HOME/bin:/usr/local/node-js/bin のように変更後保存。 $ . .bash_profile
テスト。
http://nodejs.org/にあるexample.jsを実行してみる。
$ vim example.js http://nodejs.org/のコードを打ち込む。 $ node example.js & Server running at http://127.0.0.1:8124/ $ wget http://127.0.0.1:8124/ $ less index.html Hello World
うごいた。