简体   繁体   English

无法在Google Cloud Platform上托管Django应用

[英]Unable to host Django app on Google Cloud Platform

I have built a django app and its working fine in local machine, I tried hosting it in Google Cloud Platform. 我已经构建了一个django应用程序,并且在本地计算机上可以正常工作,我尝试将其托管在Google Cloud Platform中。

  1. Created a project Google Console 创建了一个项目Google控制台
  2. Created a django VM Instance 创建了一个django VM实例
  3. I cloned the repo from bitbucket 我从bitbucket克隆了仓库
  4. Installed all the dependencies 安装所有依赖项
  5. Created a database and made sure same credentials are used in settings.py 创建了一个数据库,并确保在settings.py中使用了相同的凭据
  6. python manage.py syncdb - this is executed python manage.py syncdb-执行
  7. Python manage.py collectstatic - this is executed Python manage.py collectstatic-执行

When I created a VM Instance I was given a dedicated IP, there is already a app called Project. 创建VM实例时,我获得了专用IP,已经有一个名为Project的应用程序。 I cloned the repo beside this folder (this is the IP https://130.211.79.74 and this is the link to the default app https://130.211.79.74/Project ). 我在此文件夹旁边克隆了存储库(这是IP https://130.211.79.74 ,这是默认应用程序https://130.211.79.74/Project的链接)。 I tried accessing my app and I see a 404 error. 我尝试访问我的应用程序,但看到404错误。 Is there anything that am missing. 是否有任何遗漏的东西。

Use the good paths in your wsgi.py file : 使用wsgi.py文件中的正确路径:

import os
import sys
sys.path.append('installdir/apps/django/django_projects/my_new_project')
os.environ.setdefault("PYTHON_EGG_CACHE", "installdir/apps/django/django_projects/my_new_project/egg_cache")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_new_project.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Don't forget to reload Apache so that your modifications are taken into account. 不要忘记重新加载Apache,以便将您的修改考虑在内。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM