Serve Django to remote apache server

做~自己de王妃 提交于 2019-12-02 18:37:57

问题


computer 2=win-64bit

computer 1= ubuntu 14.04

Django=1.7 (on computer 1) (runs within a virtualenv)

python= python 2.7

Apache= apachehaus 2.4 (on coumputer 2)

Basically what I am trying to do is have a Django Apache pair on separate computers.

so computer 1 is ubuntu running the django and computer 2 is windows running apache24

I am very new to web-dev stuff but I believe it would look like the following:

Stack 1 web-access --> Apache-Loaded-mod_wsgi (computer 2) --> Django (computer 1)

or is it? I really have no idea.

Stack 2 web-access --> Apache(computer 2) --> Apache-Loaded-mod_wsgi (computer 1) --> Django (computer 1)

If I do:

python mangage.py runserver 192.xxx.x.4:8000

it works and I can see it over the network. (ubuntu)

But now I have a second computer with apache24 (windows(computer 2)) and I configure the httpd.conf file I

LoadModule wsgi_module modules/mod_wsgi.so
Listen 8000
Listen 80

and then I open httpd-vhosts.conf and this is where I get stuck. I want to the vhosts.conf to get the django instance that is running off the runserver.

Below is the httpd-vhost.conf

<VirtualHost 192.xxx.x.4:8000>
    ServerAdmin danielsauceda34@gmail.com

    ServerName 192.xxx.x.4
    ServerAlias http://192.168.1.4
    <Directory /home/daniel/Develop/Workspaces/mgi/mdcs>
        Order deny,allow
        Allow from all
    </Directory>

    WSGIScriptAlias / /home/daniel/Develop/Workspaces/mgi/mdcs/mgi.wsgi
    <Directory /home/daniel/Develop/Workspaces/mgi/mdcs/static/>
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

And my wsgi.py is the following

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mgi.settings")

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

If someone could help me figure this out I would greatly appreciate it

faq:

Q: Why on 2 computers? A: security policy.

Q: why don't you just use ngnix? A: I might assuming Stack 2 is the correct one. but apache is required at some point.

来源:https://stackoverflow.com/questions/31541109/serve-django-to-remote-apache-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!