Django的部署与Apache在AWS上 - 目录结构 [英] Django deployment with Apache on AWS -- Directory Structure

查看:152
本文介绍了Django的部署与Apache在AWS上 - 目录结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下结构的Django应用程序

I have a django app with the following structure

web/
   manage.py
   settings.py
   wsgi.py
   urls.py
   /subapp1/
   /subapp2/

在部署开发服务器的runserver ,一切环节上正常工作。当我部署整个网​​站应用程序,没有我的网页供应。没有 500 404 错误。和错误日志只显示:

When deployed on the development server runserver, everything links and works correctly. When I deploy the entire web app, none of my webpages are served. There is no 500 or 404 error. And the error logs only show:

[notice] caught SIGTERM, shutting down
[notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations

我有以下设置为我Apache2.2.2:

I have the following set up for my Apache2.2.2:

wsgi.py:

import os
import sys
import site

site.addsitedir('/home/ubuntu/.virtualenvs/venv/local/lib/python2.7/site-packages')
sys.path.append('/var/www/ec2-XXX.us-west-1.compute.amazonaws.com/')
sys.path.append('/var/www/ec2-XXX.us-west-1.compute.amazonaws.com/web')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "web.settings")

activate_env=os.path.expanduser("/home/ubuntu/.virtualenvs/venv/bin/activate_this.py")
execfile(activate_env, dict(__file__=activate_env))

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

/etc/apache2/httpd.conf

/etc/apache2/httpd.conf

WSGIScriptAlias / /var/www/ec2-XXX.us-west-1.compute.amazonaws.com/web/wsgi.py
WSGIPythonPath /var/www/ec2-XXX.us-west-1.compute.amazonaws.com/web:/home/ubuntu/.virtualenvs/venv/local/lib/python2.7/site-packages
alias /static /var/www/ec2-XXX.us-west-1.compute.amazonaws.com/web/static

<Directory /var/www/ec2-XXX.us-west-1.compute.amazonaws.com/web>
<Files wsgi.py>
Order allow, deny
Allow from all
</Files>
</Directory>

/etc/apache2/sites-available/ec2-XXX.us-west-1.compute.amazonaws.com

/etc/apache2/sites-available/ec2-XXX.us-west-1.compute.amazonaws.com

WSGIPythonPath /var/www/ec2-XXX.us-west-1.compute.amazonaws.com/web:/home/ubuntu/.virtualenvs/venv/local/lib/python2.7/site-packages
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName ec2-XXX.us-west-1.compute.amazonaws.com
        DocumentRoot /var/www/ec2-XXX.us-west-1.compute.amazonaws.com/web
        WSGIScriptAlias / /var/www/ec2-XXX.us-west-1.compute.amazonaws.com/web/wsgi.py

        <Directory /var/www/ec2-XXX.us-west-1.compute.amazonaws.com/web>
        <Files wsgi.py>
              Order allow,deny
              Allow from all
        </Files>
        </Directory>

我做了一个须藤a2ensite ec2-XXX.us-west-1.compute.amazonaws.com 有站点启用。

我如何送达阿帕奇我的网页?我意识到这可能是一个奇怪的文件结构。

How do I get my webpages served by Apache? I realize this may be a weird file structure.

推荐答案

替换您wsgi.py与WSGI你好世界,并采取Django的出来的画面。

Replace your wsgi.py with a WSGI hello world and take Django out of the picture.

如果说工作再一种可能是你正在使用的第三方扩展模块不能与Python的子间preters兼容,都死了锁定,从而导致服务器挂在请求并没有返回值。欲了解更多详情,请参阅:

If that works then one possibility is the third party extension modules you are using are not compatible with Python sub interpreters and are dead locking, causing the server to hang on the request and not return anything. For more details see:

请确保你尝试的Hello World WSGI应用程序首先,虽然,而不是仅仅跳到尝试该文档中描述的解决方案。

Make sure you try that hello world WSGI application first though rather than just jump to trying the solution described in that documentation.

这篇关于Django的部署与Apache在AWS上 - 目录结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆