在 Google Compute Engine 上使用 python 3.6 部署 Django 1.10 应用程序

Abd*_*man 4 python django google-compute-engine django-deployment google-cloud-platform

我已经使用 Django 1.10.5 和 python 3.6 创建了一个项目,现在我需要在谷歌计算引擎上部署这个项目。我已经在谷歌上搜索了很多,但找不到任何明确的指南来在计算引擎上部署我的 Django 应用程序。

我尝试过的:

  1. 创建计算引擎实例
  2. 安装python 3.6(但没有成功,这就是为什么使用预安装的python 3.5.2)
  3. 设置 pip 和 virtualenv
  4. 创建一个 virtualenv 并从 GitHub 克隆我的项目
  5. 安装requirements.txt中的所有需求
  6. 现在,当我尝试python manage.py runserver从我的目录运行我的应用程序时,它说:

Django 版本 1.10.5,使用设置 'brain.settings'

启动开发服务器于http://127.0.0.1:8000/

使用 CONTROL-C 退出服务器。

  1. 当我访问时http://127.0.0.1:8000/不加载任何页面。

如何在 Google 计算引擎上部署 Django 1.10 和 Python 3.6 应用程序?请帮帮我!提前致谢!

Tho*_*rzl 5

您所需要做的就是在 Google Cloud Platform (GCP) 上为TCP:8000.

为此,只需连接到您的GCP:控制台防火墙规则并添加新规则即可。

另外,请务必启动 Django 以侦听公共接口,并使用公共 IP 进行访问。

python manage.py runserver 0.0.0.0:8000
Run Code Online (Sandbox Code Playgroud)