我的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>来自django.core.wsgi的[client 86.45.29.184:53665] import get_wsgi_application,referer:http:// My-IP-Address / [Sun Jan 24 15:32:56.099364 2016] [wsgi :错误] [pid 9919:tid 139760998606592] [客户端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