Ubuntu安裝nvm以及連線至EC2
Ubuntu 使用 NVM 安裝 Node.js LTS
Published in
2 min readNov 23, 2017
在 Ubuntu 上安裝 Node.js 的方法有很多種,包含:apt-get install 、直接去 curl 安裝包下來作安裝等等,本篇主要使用最簡單的 NVM 套件管理工具來作安裝,且可以隨時切換想要的版本。
安裝步驟
在安裝過程中請使用一般使用者帳號,不要使用 root 帳號做安裝
Step 1. 更新 apt-get 套件內容
sudo apt-get update
Step 2. 安裝編譯套件
sudo apt-get install build-essential libssl-dev
Step 3. 下載 NVM 套件,並執行 sh 檔做安裝
curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh
Step 4. 更新環境變數,登入時會讀取使用者的個人設定檔
source ~/.profile
Step 5. 可以透過 NVM 套件去安裝想要的 Node.js 版本,建議選擇官網上面支持的 LTS (Long time support) 版本
nvm install v4.3.0
Step 6. 確認安裝後的 Node 及 NPM 版本是否為正確
node -v
npm -v
系統環境版本資訊
Ubuntu 14.04
Node 4.3.0
npm 2.1.3
redirect port 80 to port 3000:
$sudo iptables -t nat -A PREROUTING -i eth0 -p tcp — dport 80 -j REDIRECT — to-port 3000
ssh連線到ec2
$ ssh -i ~/Documents/project/happyfit-ec2key.pem ubuntu@54.255.215.0要把key轉為private :
$ chmod 0600 ~/Documents/project/happyfit-ec2key.pem
Author : Tom Hsieh (tom@appmaster.cc)