Google Cloud Platform VM 安裝 EasyEngine 教學

Share

  • Add this entry to Hatena Bookmark
GCP install EasyEngine

Google Cloud Platform 雲端主機,現在增加了台灣彰化的機房,還提供一整年的免費試用,以及註冊後就送 300 美元的活動,所以站長也使用一下這個「高富帥」的熱門產品,不過 google VM 主機入門限制比較多,在這紀錄我的看法及心得。

Google Cloud Platform 雲端主機有 2 種模式,大家比較常用 Cloud Launcher 方式一鍵開啟 WordPress 後馬上就可使用,省掉了 LANP 或 LNMP 惱人的安裝。

站長使用的是 Compute Engine VM 模式,網路上教學很多,不過你真正使用起來,SFTP 就要讓你卡關很久,後面還有一個寄信的大魔王等著你處理,不然安裝好 WordPress 後,聯絡表單根本無法使用。

所以一般 Google Cloud Platform VM 使用者,我建議:

  • 對 Linux 有一點點認識
  • 略懂 DNS 設置
  • 對主機穩定性要求很高
  • 對網路速度要求較高
  • 可以接受較高的主機租金

Google Cloud Platform 的價格:

最低配置 1 共享內核 0.6 GB RAM 硬碟 10GB HDD,每月 5 美元左右,由於 CPU、記憶體大小和硬碟大小都是可調的,所以可以根據自己的需要去購買最適合的。

流量的計算,連中國大陸 $0.23/Gbyte、美歐地區 $0.12/Gbyte,流量的價格有些小貴,但是流量是雙向的,所以是本地通過 GCE 上傳完全免費,下載還是要計費的,簡單來說 GCP 雲主機的計費方式,主機歸主機費,流量歸流量費。

Pricing Calculator 有提供價格試算,可以當做參考:

Google Cloud Pricing Calculator
Create your own Custom Price Quote for the products offered through Google Cloud based on number, usage, and power of servers

CPU 共享內核的規格:

f1-micro 微型 0.6 GB 記憶體和 g1-small 小型 1.7GB 記憶體,這兩個版本是屬於共享核心,根據 Google 的說明,0.6GB 是 0.2vCPU,1.7GB 是 0.5vCPU,但是卻支持 bursting,也就是短時間內最高能使用到 1.0 vCPU。

關於 CPU 類型,Google 有詳細的解釋:

Machine families resource and comparison guide  |  Compute Engine Documentation  |  Google Cloud
Discover more about the machine families, series, and types you can choose from to create a VM instance with Google Cloud's resource guide.

我試著開一個 f1-micro 0.6GB VM,安裝 EasyEngine (Nginx) 開 1 個 WordPress 網站,google 就已經發出資源不足的警告,如是簡單的部落格形式網站,還能硬撐過去,更不用說要安裝帶有面板的程序了。

所以,只有一個網站使用者,使用 Cloud Launcher 方式,開啟 CMS 會比較省心,又可享有 Google Cloud Platform 效能。

如果你有多個網站,又想要有高效能配置,就要選擇獨立 vCPU 3.75GB 記憶體以上的規格,費用較高的 n1-standard-1 1vCPU 3.75GB 記憶體的配置了。

了解上面說的用途及價格,我們開始申請 Google Cloud Platform 免費試用:

申請網址

Free Trial and Free Tier  |  Google Cloud
Start building on Google Cloud with 0 in free credits and free usage of 20+ products like Compute Engine and Cloud Storage, up to monthly limits.

省略申請過程,直接從新增一個專案開始

Google Cloud Platform 1

站長要安裝 EasyEngine 系統,又想效能高一點,所以配置 1vCPU 3.75GB,作業系統選擇 Ubuntu 16.04 LTS,選擇 SSD 硬碟,防火牆允許 http 及 https 都打勾,如下圖:

Google Cloud Platform 2

先不要按「建立」,先到網路選項,申請一個靜態網址:

Google Cloud Platform 3

檢查配置沒問題了,按「建立」,等待一下 Google Cloud Platform 開始建置 VM 主機。

防火牆設置:

Google Cloud Platform 默認開啟了防火牆是不能關閉的,只能允許你自己指定的協議和端口。

默認已經打開了 SSH 22 和 http / https 80 443 等端口。

回到首頁 → 網路 → 進入「防火規則」,加入 EasyEngine 必須開啟的端口。

GCP 防火牆規則

點取「建立防火牆規則」,將 22222 及 11371 這 2 個端口加入防火牆,如下圖填寫:

GCP 防火牆

Compute Engine VM 有個貼心的設計,不用再配置金鑰才能從 PuTTY 登入 SSH,建立好 VM 後,再點選剛所建立好 VM 雲主機,後方的 SSH 下拉選單,再選擇「在瀏覽器視窗中開啟」,進入 SSH 視窗模式。

Google Cloud Platform 7

執行指令,改為 root 權限,才能安裝 EasyEngine:

sudo su -

安裝 EasyEngine 前,要先做 swap 交換分區,Google Cloud Platform VM 預設置是不會有 swap 交換分區,swap 對我們這種小記憶體主機很重要,所以我們要設置 swap 分區,分區大小可依你的記憶體來判斷。

如何安裝 swap 教學,請看站長的另一篇教學

https://yungke.li/how-vultr-swap/

如何安裝 EasyEngine 教學,請看站長的另一篇教學

EasyEngine 輕鬆安裝 WordPress - HelloYUNGKE
EasyEngine 可以很輕鬆管理 nginx,它是一種非常快速的 Web 服務器程序,EasyE...

下一篇,站長再分享建立 SFTP 金鑰配置及信箱設置心得。

HelloROOT
Follow me

Share

  • Add this entry to Hatena Bookmark

Follow Me