lai85321
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # AWS Deploy Document - [連線資訊](#連線資訊) - [安裝方法](#安裝方法) - [資料庫建置](#資料庫建置) - [圖檔](#圖檔) ### 連線資訊 - 前台: http:/{IP}/mall - 使用者1 帳號: test@test.com 密碼: 123 - 使用者2 帳號: 密碼: - 後台: http:/{IP}/portal - 使用者1 帳號: test01 密碼: test01 商店: ccilu - 使用者2 帳號: test02 密碼: test02 商店: ccilu ### 安裝方法 1. 註冊AWS帳號,開啟MFA(帳號比較安全) 2. 開EC2 - 目前是使用Amazon Linux 2 AMI - instance為t2.micro - 會有一組金鑰需要存下來 3. elastic IP - 配置一個靜態 IPv4 地址 4. security group - 開啟port 80 (http) - 開啟port 27017 (mongodb) 5. 連線進EC2 - 進到EC2 console,勾選機器後按連線 ![](https://i.imgur.com/ARFpRYj.png) - 我的習慣是使用ssh 連線,可以跟著網頁上步驟執行 i. 開啟電腦的terminal後,cd到存金鑰的資料夾 ii. `chmod 400` 代表開讀取權限,第一次執行即可 iii. 可以直接複製最後一行的指令連線 (`ssh -i "aws-key.pem" ec2-user@ec2-18-179-83-121.ap-northeast-1.compute.amazonaws.com`) 7. 安裝 node - [安裝教學](https://docs.aws.amazon.com/zh_tw/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html) 建議不要直接安裝最新版的node, 可能會有error `nvm install [版本號]` 比較好 8. 安裝 mongo - [安裝教學](https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-amazon/) 9. 安裝git - ```$ sudo yum install git``` 10. 安裝pm2 - 用來管理 server 上的 Node.js 服務 - ```$ npm install pm2 -g``` 11. clone server repo - ```git clone``` - ```npm i ``` - ```add .env``` - ```pm2 start index ```(在背後執行index.js) 12. clone public repo - ```git clone``` - 將電視牆影片放到public資料夾底下 - ```npm i``` - ```add .env``` - ```npm build``` - ```pm2 start npm --name "next-js" -- dev``` 13. clone portal repo - ```git clone``` - ```npm i``` - ```add .env``` - ```npm build``` 14. 安裝nginx - `sudo amazon-linux-extras install nginx1` - ```sudo vim /etc/nginx/conf.d/default.conf``` 1. 前後端掛同一台機器 - ``` server { listen 80; location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } location ^~ /admin { alias /home/ec2-user/3D-shopping-mall-portal/; index index.html; } location /api/1.0 { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:8080; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location /peer { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:9000; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_cache_bypass $http_upgrade; } location ~* \.(png|jpeg) { add_header Access-Control-Allow-Origin * ; root /home/ec2-user/3D-Shopping-Mall-API-Sever/uploadFile/; try_files /store/$uri /merchandise/$uri $uri 404; } } 2. 前端獨立一台 ssl掛前端機台 - ``` server { listen 443 ssl; ssl_certificate /etc/ssl/certificate.crt; ssl_certificate_key /etc/ssl/private.key; access_log /var/log/nginx/nginx.vhost.access.log; error_log /var/log/nginx/nginx.vhost.error.log; server_name gawesome.com.tw; location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } location ^~ /admin { alias /home/ec2-user/3D-shopping-mall-portal/; index index.html; } } server { listen 80 default_server; server_name gawesome.com.tw; return 301 https://$host$request_uri; } - start nginx `sudo systemctl start nginx` 14. SSL 1. 買網域 godaddy 2. 申請ssl https://app.zerossl.com/dashboard 3. godaddy綁IP 4. EC2記得開443 security group 5. nginx可能會遇到403的error https://blog.51cto.com/u_4048786/3205223 嘗試成功的方法是將nginx用戶名改成root `sudo vim /etc/nginx/nginx.conf` 改為 nginx root #### 資料庫建置 目前是使用mongo compass來操作雲端的資料庫 1. 下載並安裝mongo compass https://www.mongodb.com/docs/compass/master/ 2. 連線位置設為Elastic ip 位址 ![](https://i.imgur.com/jzfZXX1.png) 3. 連線後手動import 資料進資料庫 資料放置於此[雲端連結]![Uploading file..._sn5e0p8y7] (https://drive.google.com/drive/folders/15g8Kifg15hDiashRc9KC40FLiMn0lgpR?usp=share_link),檔名對應各collection的名稱 #### 圖檔 目前已放置於S3 連線所需資料請依照後端專案的`.env template`中所列新增於`.env`中 S3架設請參考: https://www.youtube.com/watch?v=eQAIojcArRY CloudFront架設請參考: https://www.youtube.com/watch?v=-DDGYzKtNwc

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully