在 GCP (Windows Server) 使用 Apache Server + Flask + Python + LINE BOT (Part 1 - 搭建Apache Server)
目的
在 GCP 建立一個 Windows Server 的 VM,搭建 Apache Server,啟動 Flask
環境:Windows Server 2016 Datacenter + Python 3.7.6 + Apache Server 2.4.41
這篇主篇先介紹如何在 Windows Server 搭建 Apache Server
一、關閉 IE 增強式安全性設定
打開 IE 後會看到這個畫面 QQ
所以要更改 IE Enhanced Security Configuration,打開 Server Manager
看到 IE Enhanced Security Configuration 被設置為 On ( !!!!! 這裡截到我已經更改完的畫面惹XD 所以截圖顯示為 Off)
然後點它,把 Administrators 和 Users 都選 Off,再按 OK
這樣在 IE 就可以瀏覽網頁惹 (YA)
二、安裝 Python (Version 3.7.6)
Python 官網 : https://www.python.org/downloads/
在這裡我下載 Python 3.7.6
在 GCP (Windows Server) 使用 Python + Flask + LINE BOT (Part 1)
目的:在 Windows Server 使用 Python Flask 作為 LINE BOT callback 使用
一、安裝 Python 3.7.6
二、安裝 virtualenv、 virtualenvwrapper-win
三、使用 Python 虛擬環境
一、安裝 Python
Python 官網 : https://www.python.org/downloads/
這邊我下載的 Python 版本是 3.7.6
下載完成後,使用系統管理員的權限開啟
按照步驟安裝,打勾 Add Python 3.7 to PATH
NEXT NEXT … 就安裝完成啦
打開 cmd,確認一下
$ python -VPython 3.7.6
三、安裝 Apache (VC15-Apache-2.4.41-Win64)
到 Apache 的下載頁面 : https://www.apachelounge.com/download/VC15/
下載 httpd-2.4.41-win64-VC15.zip 並解壓縮
然後到路徑 httpd-2.4.41-win64-VC15/Apache24/bin/,輸入 cmd
在 cmd 上輸入 httpd,結果....QQ 出現錯誤訊息QQ
The program can't start because VCRUNTIME140.dll is missing from your computer. Try reinstalling the program to fix this problem.
估狗惹一下,應該是 GCP Windows Server 沒有安裝 Visual Studio C++
到 Microsoft Support 網頁下載 : https://support.microsoft.com/en-in/help/2977003/the-latest-supported-visual-c-downloads
複製到 GCP Windows Server IE,結果... =_=
Javascript is disabled
所以先在本機端複製好連結,直接貼過去吧QQ
x64: vc_redist.x64.exe
安裝完成後,重複剛剛的動作 cmd ---> httpd
結果又報錯了=_=
httpd: Syntax error on line 39 of C:/Users/ /Downloads/httpd-2.4.41-win64-VC15/Apache24/conf/httpd.conf: ServerRoot must be a valid dirctory
嗯… 要把它 Apache24/ 放到 C:/ 底下
(YA) 成功惹 !!!!!
到 IE 輸入 localhost 測試一下
四、安裝 mod_wsgi
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi
下載版本相同 (Apache、Python、Windows )的 mod_wsgi
剛剛下載的 Apache : VC15、Python 3.7.6、Windows Server 64bit
所以下載的是 mod_wsgi‑4.7.0+ap24vc15‑cp37‑cp37m‑win_amd64.whl
Reference
- 如何在 Windows Server 2012 開啟或關閉【IE 增強式安全性設定】(一點通系列 — MVP 撰寫)
2. The latest supported Visual C++ downloads