express の examples

node の express を git clone して examples を動かそうとしてもどうもエラーになる
色々試しているうちに動いた

ログをとってなかったので、とりあえず記憶を頼りに(ならないけど)
覚えてる範囲でメモ

動かなかった原因は node と express のバージョン不一致

インストールしていた node のバージョンが v0.5 系 で
express が v3.x 系(?かな) の組み合わせはだめだったから

これを node はバージョンが v0.4 系
express は v2.x 系にすることでエラーが解消した

前提として
OS: CentOS 5.7 (64bit)
node が /root/ 下に git clone してある
express が /home/mitsuaki/ 下に git clone してある

まず node のソースを git clone した ディレクトリにいって

[root@localhost ~]# git checkout v0.4.12

多分、↓ でもよかったはずだと思う

[root@localhost ~]# git checkout v0.4

master じゃなないところに "*"があればOKだと思う

[root@localhost node]# git branch
* (no branch)
master

そしたら、 ./configure → make → make install でうまく行くと ↓ のように

[root@localhost node]# node --version
v0.4.12

https://github.com/joyent/node/wiki/Installation Step4 に従い npm も入れなおす

[root@localhost node]# curl http://npmjs.org/install.sh | sh

次に express を git clone した ディレクトリにいって

[mitsuaki@localhost express]$ git branch master 2.x

さらに

[mitsuaki@localhost express]$ npm install -d

ガリガリとインストールが始まって、うまく行くと ↓ のように

[mitsuaki@localhost express]$ express --version
2.5.0

examples を動かし http://localhost:3000/ をリクエストすると

[mitsuaki@localhost express]$ node examples/jade/app.js
Express app started on port 3000
GET / 200 82ms
GET /stylesheets/style.css 304 7ms

/usr と /usr/local の使い分け



Linux になんか make して install するのに、 /usr と /usr/local ってどうやって使い分けたらいいんだって思ってたら、そういうことなのかと合点がいく記事があったので、そこんとこだけ適当に訳してみました< Linux's directory structure - 1.2 >
http://www.tuxfiles.org/linuxhelp/linuxdir.html

原文

< /usr/local >

This is where you install apps and other files for use on the local machine. If your machine is a part of a network, the /usr directory may physically be on another machine and can be shared by many networked Linux workstations. On this kind of a network, the /usr/local directory contains only stuff that is not supposed to be used on many machines and is intended for use at the local machine only.

Most likely your machine isn't a part of a network like this, but it doesn't mean that /usr/local is useless. If you find interesting apps that aren't officially a part of your distro, you should install them in /usr/local. For example, if the app would normally go to /usr/bin but it isn't a part of your distro, you should install it in /usr/local/bin instead. When you keep your own programs away from the programs that are included in your distro, you'll avoid confusion and keep things nice and clean.


抄訳
ここはローカルマシンで使うためのアプリやらその他のファイルなんかを入れるところ。もしあなたのマシンがネットワーク上の1つなら /usr ディレクトリは多分、物理的に別なマシンにあって、他の多くの Linux ワークステーションで共有されてることでしょう。こんな感じのネットワークでは /usr/local ディレクトリには、他の多くの Linux ワークステーションでは使われなさそうで、ローカルマシンだけで使うやつだけを入れときます。

もっとも、あなたのマシンはこんな感じのネットワーク上ではないだろうけど、/usr/local は無用ってわけじゃないよ。あなたが使ってるディストリビューションで公式じゃないけど気に入ったアプリがあったら、そんなのを /usr/local に入れるといい。例えば、普通、 /usr/bin に入れるようなアプリで、使ってるディストリビューションに含まれないんだったら、代わりに /usr/local/bin に入れるといい。自分で入れたプログラムをディストリビューションのから分けといたら、混乱するの避けられるし、ものごとをいい感じで整理しとけるよ。



なるほど〜

Mongodb をインスコ




まずはこちらのページにしたがって yumリポジトリに追加

http://www.mongodb.org/display/DOCS/CentOS+and+Fedora+Packages

[root@localhost yum.repos.d]# pwd
/etc/yum.repos.d
[root@localhost yum.repos.d]# cat 10gen.repo
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0

[root@localhost yum.repos.d]#

ヘタレなのでパッケージマネージャーでインスコ

めんどっちーの下を参考に root でディレクトリを作って、すぐサーバを起動

http://www.mongodb.org/display/DOCS/Quickstart+Unix

[root@localhost ~]# mkdir -p /data/db
[root@localhost ~]# cd /usr/bin
[root@localhost bin]# ./mongod
./mongod --help for help and startup options
Sun Oct 23 21:08:59 [initandlisten] MongoDB starting : pid=26177 port=27017 dbpath=/data/db/ 64-bit host=localhost.localdomain
Sun Oct 23 21:08:59 [initandlisten] db version v2.0.1, pdfile version 4.5
Sun Oct 23 21:08:59 [initandlisten] git version: 3a5cf0e2134a830d38d2d1aae7e88cac31bdd684
Sun Oct 23 21:08:59 [initandlisten] build info: Linux bs-linux64.10gen.cc 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41
Sun Oct 23 21:08:59 [initandlisten] options: {}
Sun Oct 23 21:08:59 [initandlisten] journal dir=/data/db/journal
Sun Oct 23 21:08:59 [initandlisten] recover : no journal files present, no recovery needed
Sun Oct 23 21:08:59 [initandlisten] preallocateIsFaster=true 8.28
Sun Oct 23 21:09:00 [initandlisten] preallocateIsFaster=true 8.78
Sun Oct 23 21:09:01 [initandlisten] preallocateIsFaster=true 8.74
Sun Oct 23 21:09:01 [initandlisten] preallocating a journal file /data/db/journal/prealloc.0
356515840/1073741824 33%
744488960/1073741824 69%
Sun Oct 23 21:09:09 [initandlisten] preallocating a journal file /data/db/journal/prealloc.1
639631360/1073741824 59%
Sun Oct 23 21:09:16 [initandlisten] preallocating a journal file /data/db/journal/prealloc.2
587202560/1073741824 54%
Sun Oct 23 21:09:22 [websvr] admin web console waiting for connections on port 28017
Sun Oct 23 21:09:22 [initandlisten] waiting for connections on port 27017

別な term で疎通をとってみた

[mitsuaki@localhost ~]$ /usr/bin/mongo
MongoDB shell version: 2.0.1
connecting to: test
> db.foo.save( { a: 1 })
> db.foo.find()
{ "_id" : ObjectId("4ea4043d442da8cab402a458"), "a" : 1 }
> exit
bye
[mitsuaki@localhost ~]$

芽出度し、芽出度し

Python 2.7.2 をインスコ




とりあえず Python を入れようと、ターッ して ./configure したらエラーになってしまった

[root@localhost Python-2.7.2]# ./configure
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... linux2
checking EXTRAPLATDIR...
checking machine type as reported by uname -m... x86_64
checking for --without-gcc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/tmp/Python-2.7.2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[root@localhost Python-2.7.2]#

どうも下をみると gcc を入れればいいっぽい
http://labs.agenda-style.jp/blog/2010/01/linux-tips---configure-error-no-acceptable-c-compiler-found-in-path--.html

ヘタレなのでパッケージマネージャから gcc を入れる



再び ./configure して、こんどはよさげだ
Makefile が作られてた

〜省略〜
checking for build directories... done
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Modules/Setup.config
config.status: creating Misc/python.pc
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
creating Modules/Setup
creating Modules/Setup.local
creating Makefile
[root@localhost Python-2.7.2]#

make と make install をして...
よし入ったっぽい

[root@localhost Python-2.7.2]# python
Python 2.7.2 (default, Oct 23 2011, 17:18:39)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

Windows XP しかインターネット接続共有使えない



仕事で PC に入れている VMware Player では、仮想ネットワーク アダプタの設定の構成をホストオンリー ネットワークにして、Windows のインターネット接続の共有機能でネットワークに接続している

これが NAT やブリッジ とかよりお手軽だし気に入っている
ポートは全部使えるし、別な NIC はいらないし



それで自宅の PC でも同じことをしようと思ったがうまくいかない
ネットワーク接続の共有を設定して、OK すると Windows がネットワークの設定をかえまっせっていうダイアログが出る

そいつはイタダケナイ



そこでよくよくVMware Player ヘルプを読んでみると、こんなことが書いてある

VMware Player ヘルプ : 仮想マシンのハードウェア設定の構成 : 仮想ネットワーク アダプタの設定の構成 : ホストオンリー ネットワークの構成

ホストオンリー ネットワークの構成


〜 省略 〜
Windows XP および Windows 2003 ホスト システムでは、ホストオンリー ネットワークを Windows のインターネット接続の共有機能と組み合わせて使用できます。
〜 省略 〜

どうも、 Windows Vista や 7 じゃうまくいかないようだ
Vista にインストールした Parallels Desktop でやったときもうまくいかなかった


もー


結局 USB の WiFi を買ってブリッジ接続している

そういうわけで私のノートPC には WiFi が内臓されているのに USB の WiFi も挿しているわけだ

めでたしめでたし