Apache 上的 Django 网站 wsgi 失败

Django website on Apache with wsgi failing

所以我即将开始我的第一个 django 网站,我目前有一个配置为托管 php 网站的服务器,我决定测试一个简单的空项目以熟悉进程

所以此服务器中的 python 版本有点旧 (2.6) 所以我无法安装最新版本的 django,我安装了 1.6 因为它只是一个不重要的测试(我要升级python 当我的网站准备好午餐时的版本)

所以我安装了 django 并在这个可怕的环境中创建了一个名为 testing 的新项目

/home/sdfds34fre/public_html/

您可以使用此域名查看

http://novadmin20.com

在阅读了关于 django 的文档后(不幸的是,他们已经删除了 1.6 的文档,我不得不使用 1.9)和 wsgi,我已经像这样更新了我的 httpd.conf

<VirtualHost 111.111.111.111:80>
    ServerName 111.111.111.111
    DocumentRoot /usr/local/apache/htdocs
    ServerAdmin somemeail@gmail.com
    <IfModule mod_suphp.c>
        suPHP_UserGroup nobody nobody
    </IfModule>

    <Directory /home/sdfds34fre/public_html/testing/testing>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>


    WSGIDaemonProcess testing python-path=/home/sdfds34fre/public_html/testing:/usr/lib64/python2.6/site-packages/
    WSGIProcessGroup testing
    WSGIScriptAlias / /home/sdfds34fre/public_html/testing/testing/wsgi.py


</VirtualHost>

但即使在我转到

时重新启动 httpd 服务之后
http://novadmin20.com/testing/

我只看到目录列表,我是不是遗漏了什么?

这是我的 wsgi.py 文件

"""
WSGI config for testing 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.6/howto/deployment/wsgi/
"""

import os
import sys

sys.path.append(os.path.dirname(os.path.dirname(__file__)))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testing.settings")

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

DocumentRoot 指令是您问题的主要根源。 (ref)

试试这个配置:

<VirtualHost 111.111.111.111*:80>
 ServerName novadmin20.com

 WSGIDaemonProcess testing python-path=/home/sdfds34fre/public_html/testing:/usr/lib64/python2.6/site-packages/
 WSGIScriptAlias / /home/sdfds34fre/public_html/testing/testing/wsgi.py

  <Directory /home/sdfds34fre/public_html/testing/testing>
     <Files wsgi.py>
      Order deny,allow
      Require all granted
      WSGIProcessGroup testing
    </Files>
   </Directory>

</VirtualHost>