直播時間:5/11 (四) 20:00 ~ 21:00 校園大使:Andy Lee, Johnny Yeng
可自己部署亦可參考下列方法
- 註冊 AWS Educate 帳號
- 開啟 EC2 Lab
- EC2 的「安全群組」需允許 port 3000 的傳入規則
- 從 AWS Educate
Details
裡複製 Credentials - 因這次工作坊會在 port 3000 上,需在安全群組裡允許傳入規則
加入以下 key pair
HOST_DNS
:<PUBLIC_IPV4_DNS>USERNAME
:ec2-userEC2_SSH_KEY
:<YOUR_SSH_KEY>
sudo yum update
sudo yum install git -y
git clone <YOUR_OWN_REPO>
- Connect to your Linux instance as ec2-user using SSH.
- Install node version manager (nvm) by typing the following at the command line.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
We will use nvm to install Node.js because nvm can install multiple versions of Node.js and allow you to switch between them.
-
Activate nvm by typing the following at the command line.
. ~/.nvm/nvm.sh
-
Use nvm to install the latest version of Node.js by typing the following at the command line.
Amazon Linux 2 does not currently support the current LTS release (version 18.x) of Node.js. Use Node.js version 16.x with the following command instead.
nvm install 16 nvm use 16
Installing Node.js also installs the Node Package Manager (npm) so you can install additional modules as needed.
-
Test that Node.js is installed and running correctly by typing the following at the command line.
node -e "console.log('Running Node.js ' + process.version)"
This displays the following message that shows the version of Node.js that is running.
Running Node.js VERSION
- 進到專案資料夾
cd 2023-05-11_Hexschool_Tutorial
- 安裝相依套件
npm install npm install pm2 -g
- 執行
pm2 start index.js
- 使用無痕或是另一個瀏覽器開 S3 Lab
- 建立 S3 儲存佇體
region
:us-east-1
bucket-name
: <YOUR_S3_NAME>
為了我們專案能成功上傳檔案至 S3,需要有 S3 的上傳 credentials。
建議作法是透過 API Gateway 加上適當的權限,方便起見我們這裡是直接使用 Token + Access Key
注意!如果是使用 AWS Educate 的方式開分別開兩個 Lab,這裡的 credentials 是 S3 的 Lab!