Install Node.js in AWS m1 server
如果有人看上AWS m1 instance上的免費750小時服務,又想要玩Node.js的
下面是安裝步驟,給大家參考:
- 下載node原始碼,並解壓縮
- 安裝Compile必要套件:
- 安裝gcc++
- 安裝openssl-dev
- 安裝make
- 編譯node.js原始碼(我喜歡編譯到$HOME/node目錄,再到~/.bash_rc增加PATH設定即可)
以下是執行過程(紅色部分是指令,藍色部分是我選擇的套件):
[ec2-user@ip-10-166-202-213 ~]$ wget http://nodejs.org/dist/v0.6.14/node-v0.6.14.tar.gz
--2012-04-06 14:49:49-- http://nodejs.org/dist/v0.6.14/node-v0.6.14.tar.gz
正在查找主機 nodejs.org... 8.12.44.238
正在連接 nodejs.org|8.12.44.238|:80... 連上了。
已送出 HTTP 要求,正在等候回應... 200 OK
長度: 10742747 (10M) [application/octet-stream]
Saving to: `node-v0.6.14.tar.gz'
100%[======================================================================================>] 10,742,747 28.9M/s in 0.4s
2012-04-06 14:49:50 (28.9 MB/s) - `node-v0.6.14.tar.gz' saved [10742747/10742747]
[ec2-user@ip-10-166-202-213 ~]$ tar -xzf node-v0.6.14.tar.gz
[ec2-user@ip-10-166-202-213 ~]$ cd node-v0.6.14
[ec2-user@ip-10-166-202-213 node-v0.6.14]$ yum search gcc
Loaded plugins: fastestmirror, priorities, security, update-motd
Determining fastest mirrors
* amzn-main: packages.us-west-1.amazonaws.com
* amzn-updates: packages.us-west-1.amazonaws.com
amzn-main | 2.1 kB 00:00
amzn-main/primary_db | 2.1 MB 00:00
amzn-updates | 2.3 kB 00:00
amzn-updates/primary_db | 30 kB 00:00
======================================================= N/S Matched: gcc =======================================================
gcc-c++.x86_64 : C++ support for GCC
gcc-gnat.x86_64 : Ada 95 support for GCC
gcc-objc.x86_64 : Objective-C support for GCC
...(Skip)
libquadmath.i686 : GCC __float128 shared support library
libquadmath.x86_64 : GCC __float128 shared support library
libquadmath-devel.x86_64 : GCC __float128 support
Name and summary matches only, use "search all" for everything.
[ec2-user@ip-10-166-202-213 node-v0.6.14]$ sudo yum install gcc-c++.x86_64
Loaded plugins: fastestmirror, priorities, security, update-motd
Loading mirror speeds from cached hostfile
* amzn-main: packages.us-west-1.amazonaws.com
* amzn-updates: packages.us-west-1.amazonaws.com
amzn-main | 2.1 kB 00:00
amzn-updates | 2.3 kB 00:00
...(Skip)
Installing : gcc-c++-4.4.6-3.45.amzn1.x86_64 12/12
Installed:
gcc-c++.x86_64 0:4.4.6-3.45.amzn1
Dependency Installed:
binutils.x86_64 0:2.20.51.0.7-8.29.amzn1 cloog-ppl.x86_64 0:0.15.7-1.2.5.amzn1 cpp.x86_64 0:4.4.6-3.45.amzn1
gcc.x86_64 0:4.4.6-3.45.amzn1 glibc-devel.x86_64 0:2.12-1.47.37.amzn1 glibc-headers.x86_64 0:2.12-1.47.37.amzn1
kernel-headers.x86_64 0:3.2.12-3.2.4.amzn1 libgomp.x86_64 0:4.6.2-1.27.amzn1 libstdc++-devel.x86_64 0:4.4.6-3.45.amzn1
mpfr.x86_64 0:2.4.2-1.7.amzn1 ppl.x86_64 0:0.10.2-11.5.amzn1
Complete!
[ec2-user@ip-10-166-202-213 node-v0.6.14]$ yum search openssl
Loaded plugins: fastestmirror, priorities, security, update-motd
Loading mirror speeds from cached hostfile
* amzn-main: packages.us-west-1.amazonaws.com
* amzn-updates: packages.us-west-1.amazonaws.com
===================================================== N/S Matched: openssl =====================================================
openssl-devel.x86_64 : Files for development of applications which will use OpenSSL
openssl-perl.x86_64 : Perl scripts provided with OpenSSL
...(Skip)
perl-Net-SSLeay.x86_64 : Perl extension for using OpenSSL
Name and summary matches only, use "search all" for everything.
[ec2-user@ip-10-166-202-213 node-v0.6.14]$ sudo yum install openssl-devel.x86_64
Loaded plugins: fastestmirror, priorities, security, update-motd
Loading mirror speeds from cached hostfile
* amzn-main: packages.us-west-1.amazonaws.com
...(Skip)
Installing : openssl-devel-1.0.0g-1.26.amzn1.x86_64 7/7
Installed:
openssl-devel.x86_64 0:1.0.0g-1.26.amzn1
Dependency Installed:
keyutils-libs-devel.x86_64 0:1.4-3.9.amzn1 krb5-devel.x86_64 0:1.9-22.20.amzn1 libcom_err-devel.x86_64 0:1.42-2.15.amzn1
libselinux-devel.x86_64 0:2.1.6-6.12.amzn1 libsepol-devel.x86_64 0:2.1.3-2.11.amzn1 zlib-devel.x86_64 0:1.2.3-27.9.amzn1
Complete!
[ec2-user@ip-10-166-202-213 node-v0.6.14]$ ./configure --prefix=~/node
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for program gcc or cc : /usr/bin/gcc
Checking for gcc : ok
Checking for library dl : yes
Checking for openssl : yes
Checking for library util : yes
Checking for library rt : yes
Checking for fdatasync(2) with c++ : yes
'configure' finished successfully (0.471s)
[ec2-user@ip-10-166-202-213 node-v0.6.14]$ make
Waf: Entering directory `/home/ec2-user/node-v0.6.14/out'
DEST_OS: linux
DEST_CPU: x64
Parallel Jobs: 1
Product type: program
[ 1/35] copy: src/node_config.h.in -> out/Release/src/node_config.h
[ 2/35] cc: deps/http_parser/http_parser.c -> out/Release/deps/http_parser/http_parser_3.o
/usr/bin/gcc -rdynamic -pthread -g -O3 -DHAVE_OPENSSL=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_FDATASYNC=1 -DARCH="x64" -DPLATFORM="linux" -D__POSIX__=1 -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -IRelease/deps/http_parser -I../deps/http_parser ../deps/http_parser/http_parser.c -c -o Release/deps/http_parser/http_parser_3.o
...(Skip)
[ec2-user@ip-10-166-202-213 node-v0.6.14]$ make install
Waf: Entering directory `/home/ec2-user/node-v0.6.14/out'
DEST_OS: linux
DEST_CPU: x64
Parallel Jobs: 1
Product type: program
* installing deps/uv/include/ares.h as /home/ec2-user/node/include/node/ares.h
* installing deps/uv/include/uv.h as /home/ec2-user/node/include/node/uv.h
* installing deps/uv/include/ares_version.h as /home/ec2-user/node/include/node/ares_version.h
...(Skip)