无法使用Jelastic呈现Django应用程序

2024-09-30 01:36:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用杰拉蒂克来渲染我的Django

我在jelastic上克隆了我的Django应用程序。 enter image description here

我配置了我的Postgres数据库并修改了我的settings.py,以便我的应用程序连接到我的数据库

enter image description here

最后,为了呈现我的应用程序,我在SSH:python manage.py运行服务器中运行这个 一切似乎都正常:

enter image description here

但我在我的浏览器上得到了这样的回应:

enter image description here

任何帮助都将不胜感激=)


Tags: djangopy服务器数据库应用程序settingsmanage浏览器
2条回答

我们可以看到,站点是在本地主机(127.0.0.1)和端口8000上手动启动的。然后尝试从外部打开域(尽管应用程序仅在127.0.0.1 localhost上侦听,并且仅在端口8000上侦听)。显然,没有打开任何响应,因为Apache正在侦听端口80,该端口未配置为使用此应用程序(并且应用程序本身也无法从外部访问)。 为了让Apache+mod_wsgi能够成功地使用该应用程序,不需要像以前那样手动启动该应用程序,但需要编写一个类似于此处描述的https://jelastic.com/blog/django-cms-installation-python-cloud-hosting/(手动安装的第6点)的wsgi入口点

因此,我了解了如何修改apache服务器文件,将您自己的django web应用程序放在Jelastic解决方案上:

转到文件:/etc/httpd/conf.d/wsgi.conf

进行以下修改:

#       Put this in comment line      

#Alias /images /var/www/webroot/ROOT/images
#Alias /static /var/www/webroot/ROOT/static

#WSGIScriptAlias / ${WSGI_SCRIPT}
#WSGIProcessGroup apache

#       Add those code line      


WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
WSGIPythonHome /path/to/venv
WSGIPythonPath /path/to/mysite.com

<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>

Alias /media/ /path/to/mysite.com/media/
Alias /static/ /path/to/mysite.com/static/

<Directory /path/to/mysite.com/static>
Order deny,allow
Allow from all
</Directory>

<Directory /path/to/mysite.com/media>
Order deny,allow
Allow from all
</Directory>

相关问题 更多 >

    热门问题