Mod_wsgi , django and apache not working correctly

我是研究僧i 提交于 2019-12-08 05:13:39

问题


Configuration :

Application location: /home/cha0s/hello

Wsgi file directory: /home/cha0s/hello/apache/django.wsgi

django.wsgi

import os
import sys


path = '/home/cha0s/hello'
if path not in sys.path:
    sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODEULE']='hello.settings'



import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Apache file : /etc/apache2/sites_available/hello

hello

<VirtualHost *:80>

    ServerName blabla.com
    DocumentRoot /home/cha0s/hello




    WSGIScriptAlias http://blabla.com /home/cha0s/hello/apache/django.wsgi

    <Directory /home/cha0s/hello/apache>
        Order allow,deny
        Allow from all
    </Directory>


</VirtualHost>

Question:

So the problem is it kind of works , but it opens directory just like a list of files , not like a django website. Any idea whats wrong? I read somewhere on stackoverflow that mod_python may be the problem , so i deleted it .


回答1:


You need to add '/home/cha0s' to sys.path.

Also go watch:

http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations

This explains other things you could have got wrong, but since you don't explain what the error is you are getting, hard to tell what else is broken.




回答2:


Your WSGIScriptAlias line is nonsense. It's a path, not a URL. Should be:

WSGIScriptAlias / /home/cha0s/hello/apache/django.wsgi

Also, you've misspelled DJANGO_SETTINGS_MODULE in the wsgi file.



来源:https://stackoverflow.com/questions/9047369/mod-wsgi-django-and-apache-not-working-correctly

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