试图在Apache2上设置Django:'无法导入'django.core.wsgi

时间:2016-01-24 16:46:35

标签: python django ubuntu apache2 mod-wsgi

我的Django设置在本地运行,但是当我尝试在Ubuntu上使用Apache2运行它并转到IP时,它会给我一个500内部错误消息内部服务器错误

  

“服务器遇到内部错误或配置错误,而且是   无法完成您的请求。“

检查我的错误日志我发现'django.core.wsgi'存在问题。错误消息是:

  

Traceback(最近一次调用最后一次):,referer:http:// My-IP-Address /   [Sun Jan 24 15:32:56.099311 2016] [wsgi:error] [pid 9919:tid 139760998606592]

     

[client 86.45.29.184:53665]文件   “/home/USER/my_django_project/my_django_project/wsgi.py”,第17行,in   ,referer:http:// My-IP-Address /

     

[Sun Jan 24 15:32:56.0993522016] [wsgi:error] [pid 9919:tid 139760998606592> [client]   86.45.29.184:53665]来自django.core.wsgi import get_wsgi_application,referer:http:// My-IP-Address /

     

[Sun Jan 24 15:32:56.099364 2016] [wsgi:error] [pid 9919:tid 139760998606592]   [client 86.45.29.184:53665] ImportError:没有名为的模块   django.core.wsgi,referer:http:// My-IP-Address /

我的etc / apache2 / sites-enabled 文件夹有我的my_django_project.conf文件,这是建立为:

WSGIScriptAlias / /home/USER/my_django_project/my_django_project/wsgi.py
WSGIPythonPath /home/USER/my_django_project

<Directory /home/USER/my_django_project/my_django_project>
    <Files wsgi.py>
        Order deny,allow
        Require all granted
    </Files>
</Directory>

Alias /media/ /home/USER/my_django_project/django_proj/media/
Alias /static/ /home/USER/my_django_project/django_proj/static/

<Directory /home/USER/my_django_project/django_proj/static>
    Require all granted
</Directory>

<Directory /home/USER/my_django_project/django_proj/media>
    Require all granted
</Directory>

我的wsgi.py文件如下:

"""
WSGI config for my_django_project project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/
"""

import os, sys

sys.path.append('/home/USER/.local/lib/python2.7/site-packages')

sys.path.append('/home/USER/my_django_project/my_django_project')


from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_django_project.settings")

application = get_wsgi_application()

感谢您的阅读  :d

0 个答案:

没有答案