Mod_wsgi , django and apache not working correctly

2019-06-06 19:29发布

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 .

2条回答
Emotional °昔
2楼-- · 2019-06-06 20:12

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.

查看更多
等我变得足够好
3楼-- · 2019-06-06 20:17

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.

查看更多
登录 后发表回答