需要 Gunicorn Nginx Step 1. 部屬Flask app程式碼 複製程式碼到指定位置 e.g /var/www/flaskapp $ sudo mkdir /var/www/flaskapp $ sudo chmod 777 /var/www/flaskapp Step 2. 安裝WSGI Server (Gunicorn) 安裝 sudo apt-get install gunicorn or pip install gunicorn Step 3. 安裝web server (Nginx) sudo apt-get install nginx 設定 sudo vim /etc/nginx/site-avalidable/default 將內容改成如下 server { listen 80; server_name 10.36.172.142; # external domain name location / { proxy_pass http://0.0.0.0:5678 ; # point to gunicorn host address proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 啟動 sudo service nginx restart Step 4. 啟動Gunicorn gunicorn -w 4 -b 0.0.0.0:5678 {主程式檔名}:{flask實體名稱} 假設我們主程式叫做main.py內容如下 from flask import Flask app = Flask(__name__) if __name__ == '__main__':