简体   繁体   English

Django + Apache + Mod_wsgi导致500内部服务器错误(附加日志)

[英]Django + Apache + Mod_wsgi cuasing 500 Internal Server Error (log attached)

Django WSGI Script Won't load due to a Python issue 由于Python问题,无法加载Django WSGI脚本

After a day of research, still couldn't solve the issue. 经过一天的研究,仍然无法解决问题。 Server is Online, using site in using virtulenv Windows 8-64bit, python34, Wamp server apache 64bit 服务器处于联机状态,使用virtulenv Windows 8-64bit,python34,Wamp服务器apache 64bit中的站点

Inside conf: 内部conf:

Listen 8080
NameVirtualHost 127.0.0.1:8080
<VirtualHost *:8080> 
ServerAdmin admin@hotmail.com
ServerName 192.168.0.101:8080 
DocumentRoot "C:/wamp/www/venv/testweb10/testweb10"  
</VirtualHost>

WSGIScriptAlias / "C:/wamp/www/venv/testweb10/testweb10/wsgi.py"
WSGIPythonPath "C:/wamp/www/venv/Lib/site-packages"

<Directory "C:/wamp/www/venv/testweb10">
        <Files wsgi.py>
            Order deny,allow
            Require all granted
        </Files>
</Directory>

Settings.py Settings.py

DEBUG = True

ALLOWED_HOSTS = ['testweb10']

hosts 主机

127.0.0.1       testweb10

I am suspecting if python compatibility issue 我怀疑是否存在python兼容性问题

User variables path: 用户变量路径:

C:\WINDOWS\system32;C:\Python34;C:\Python34\python.exe;C:\Python34\Scripts;C:\Python34\Lib\site-packages\django\bin;

在此处输入图片说明

Please Help 请帮忙

Do you have a reference to your virtualenv in your wsgi.py? 您在wsgi.py中是否引用了您的virtualenv? Here is a template I use on Linux for example: 例如,这是我在Linux上使用的模板:

import site
site.addsitedir('/home/mysite/venv/lib/python2.7/site-packages')
import os
import sys
sys.path.append('/home/mysite/mysite')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi

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

This is Django 1.6 btw. 这是Django 1.6 btw。 Django 1.7 has some differences in the wsgi.py Django 1.7在wsgi.py中有一些区别

For Django 1.7 the last two lines are: 对于Django 1.7,最后两行是:

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

WSGIPythonPath must include root of your project. WSGIPythonPath必须包含项目的根。

Used to specify additional directories to search for Python modules. 用于指定其他目录以搜索Python模块。 If multiple directories are specified they should be separated by a ':' if using a UNIX like system, or ';' 如果指定了多个目录,则在使用UNIX之类的系统时,应使用':'分隔;否则应使用';'。 if using Windows. 如果使用Windows。

WSGIPythonPath = "C:/wamp/www/venv/testweb10/testweb10;C:/wamp/www/venv/Lib/site-packages"

Eventually the following seems working for Django 1.8 最终以下似乎适用于Django 1.8

import site

site.addsitedir("C:/Python34/Lib/site-packages") site.addsitedir( “C:/ Python34 /库/站点包”)

import os
import sys
sys.path.append("C:/wamp/www/venv/testweb10/testweb10")

from django.core.wsgi import get_wsgi_application

os.environ["DJANGO_SETTINGS_MODULE"] = "testweb10.settings"

application = get_wsgi_application()

But getting errors now :( [mpm_winnt:notice] [pid 3788:tid 688] AH00455: Apache/2.4.9 (Win64) mod_wsgi/4.4.10 Python/3.4.3 PHP/5.5.12 configured -- resuming normal operations 但是现在却出错了:([[mpm_winnt:notice] [pid 3788:tid 688] AH00455:Apache / 2.4.9(Win64)mod_wsgi / 4.4.10 Python / 3.4.3 PHP / 5.5.12配置了-恢复正常操作

For guys having the same issue: 对于有同样问题的人:

Some suggestions(also for myself): 一些建议(也适用于我自己):

Version of every component is important 每个组件的版本都很重要

1) Install Appache or Wamp server the clean way. 1)干净地安装Appache或Wamp服务器。 Makesure delete its old regedit. 确保删除其旧注册表。

2) Get Mod_WSGI and following the install instructions carefully!!! 2)获取Mod_WSGI并仔细遵循安装说明!!!

2.5) Test the Mod_WSGI if working fine without Django 2.5)如果没有Django,可以正常工作,请测试Mod_WSGI

3) The Final step is to install python, Django, and setup the environments and conf. 3)最后一步是安装python,Django,并设置环境和conf。

4) Test and Deploy 4)测试和部署

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM