記錄如何安裝,管理主機,建置APP到程式開發等必須要用的指命及參考手冊

雲端運算產品

(1) VM(虛擬機器)部份

建立和啟動 VM 執行個體

網路

執行開機指令碼

執行關閉指令碼
管理VM

(1)將 VM 遷移至 Compute Engine
 

 

(2) APP 部份 (uploaded your web app into app engin)

(1) 測試伺服器(執行基本 Apache 網路伺服器)
(2) 安裝 Nginx(ubuntu 上 Nginx 介紹,安裝與設定)
      基本的 Nginx 設定檔結構網站所示
      (1) nginx 基礎設定教學
      (2) Nginx筆記(二)Nginx基礎
(3) 啟動及結束 nginx server 

sudo -s 
nginx -t #測試
nginx #啟動 
nginx -s stop #結束
nginx  -s reload  #重新啓動

鍵入 http://extern-IP-address  (不是https)

可以試試看可不可以連線~成功的話就會看到成功的畫面

 

(4) Python Bookshelf 應用程式
 

Bookshelf 應用程式是一個以 Python 編寫的範例網頁應用程式,用於示範如何使用各種 Google Cloud Platform (GCP) 產品,包含:

  • App Engine 彈性環境
  • Cloud SQL
  • Cloud Datastore
  • Cloud Storage
  • Cloud Pub/Sub

Bookshelf 範例應用程式採用 Flask 網頁應用程式架構,但不論您使用哪一個架構,這些概念和技術皆可適用。

您可以使用自選的其他網頁應用程式架構來實作這個應用程式,例如 Django

 

(3) Cloud SDK 元件安裝

gcloud components list  

gcloud components install app-engine-python

cloud components updateERROR: (gcloud.components.update) You cannot perform this action because this Cloud SDK installation is managed by an external package manager.Please consider using a separate installation of the Cloud SDK created through the default mechanism described at: https://cloud.google.com/sdk/

使用這種安裝方式

Apt-get is the way to install the app engine component In a Ubuntu/Debían System.

sudo apt-get update && sudo apt-get install google-cloud-sdk

sudo apt-get install  app-engine-python

以上皆有問題,最後是重新連線glcod shell 就可以使用 gcloud components install app-engine-python

但出現warnning 

WARNING: There are older versions of Google Cloud Platform tools on your system PATH. Please remove the following to avoid accidentally invoking these old tools:

修改 ~/.bash_profile 檔案,把 gcloud 下面的路徑移出:

 /usr/lib/google-cloud-sdk/bin/git-credential-gcloud.sh
/usr/bin/snap
/usr/lib/google-cloud-sdk/bin/gsutil
/usr/lib/google-cloud-sdk/bin/bq
/usr/lib/google-cloud-sdk/bin/gcloud

以上方法皆不行,最後是用了這篇文章的方法才成

https://cloud.google.com/sdk/docs/ <- It's OK

(4) Download the Hello World app

git clone https://github.com/GoogleCloudPlatform/python-docs-samples
cd python-docs-samples/appengine/standard/hello_world

(5)開始HTTP SERVER: SimpleHTTPServer 範例

在本機上建立HTTP SERVER
如要透過 Cloud Shell 指令提示啟動簡易的 Python HTTP 伺服器,請使用下列指令碼:

cd `mktemp -d` \
    && echo '<html><body>Hello World</body></html>' >./index.html \
    && python -m SimpleHTTPServer 8080

(6)Test the application

dev_appserver.py app.yaml

(7) Deploy your app

gcloud app deploy

(8) View your application

To launch your browser and view the app at http://[YOUR_PROJECT_ID].appspot.com, run the following command:

gcloud app browse 

參考資料:

Running Jupyter Notebook on Google Cloud Platform in 15 min
使用網頁預覽功能
Deploying a Python Flask Web Application to App Engine Flexible
Getting Started with Flask on App Engine Standard Environment
Deploying Dash to Google App Engine

Beginner’s Guide to Deploying a Django + PostgreSQL project on Google Cloud’s Flexible App Engine

GCP Day3 安裝Ubuntu桌面與遠端

 

 

 

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 stanley 的頭像
    stanley

    史坦利Stanley程式Maker的部落格

    stanley 發表在 痞客邦 留言(0) 人氣()