为什么我的Django安装提供空的HTTP响应? (额外)

时间:2013-08-05 20:39:33

标签: python django wsgi

我的问题是基于下面链接的问题。我有完全一样的问题。但建议的修复程序对我不起作用。

Why is my Django installation delivering an empty HTTP response?

以下是我已经尝试的项目列表。

  1. 删除/ etc / apache2 / mods-enabled / etc / apache2 / mods-available目录中的mod_python加载文件
  2. 在/ etc / apache2 / mods-enabled和/ etc / apache2 / mods-available目录中删除了PHP4_Load文件
  3. grep for / mod / apache2 / mods-enabled中的“mod_python”,“python_module”,/ etc / apache2 / mods-available和etc / apache2目录,但没有找到任何引用。

    < / LI>
  4. 在django.wsgi文件中测试过“Hello world”示例,它运行正常。

  5. 检查了apache错误日志。输出低于。没有错误,似乎已创建解释器。

  6.   

    [Mon Aug 05 15:32:31 2013] [info] mod_wsgi(pid = 9246):创建   翻译'www.example.com |'。

    1. Ran apache2ctl -M结果如下。
      • Ran Loaded Modules:
      • core_module(静态)
      • log_config_module(静态)
      • logio_module(静态)
      • mpm_prefork_module(静态)
      • http_module(静态)
      • so_module(静态)
      • alias_module(共享)
      • auth_basic_module(共享)
      • authn_file_module(共享)
      • authz_default_module(共享)
      • authz_groupfile_module(共享)
      • authz_host_module(共享)
      • authz_user_module(共享)
      • autoindex_module(共享)
      • deflate_module(共享)
      • dir_module(共享)
      • env_module(shared)
      • mime_module(共享)
      • negotiation_module(shared)
      • reqtimeout_module(共享)
      • setenvif_module(共享)
      • status_module(shared)
      • wsgi_module(共享)
      • 语法确定
    2. 我仍然收到空白页面响应(除非启用了hello world)。

      还有其他建议吗?我可以在其他任何地方寻找mod_python加载吗?

      django.wsgi文件

      #/usr/bin/python
      
      import os
      import sys
      import django.core.handlers.wsgi
      
      
      paths = ('/var/www/example.com/django/mysite',)
      for path in paths:
          if path not in sys.path:
                  sys.path.append(path)
      
      os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
      
      application = django.core.handlers.wsgi.WSGIHandler()
      

      django.wsgi hello world示例(启用时)

      def application(environ, start_response):
         status='200 OK'
         output='Hello Yall'
         print >> environ['wsgi.errors'], "application debug #1"
      
      response_headers = [('Content-type', 'text/plain'),
                          ('Content-Length', str(len(output)))]
      
         if environ['wsgi.url_scheme'] == 'https':
               environ['HTTPS'] = 'on'
      
         start_response(status, response_headers)
         print >> environ['wsgi.errors'], "application debug #2"
      
         return [output]
      

      Apache文件

      <VirtualHost *:80>
              ServerName example.com
              ServerAlias example.com
              ServerAlias example.com
              ServerAdmin example@example.com
      
      
             DocumentRoot /var/www/example.com
             <Directory /var/www/example.com>
              Order allow,deny
              Allow from all
             </Directory>
      
             WSGIScriptAlias / /var/www/example.com/django/mysite/apache/django.wsgi
             <Directory /var/www/example.com/django/mysite/apache>
                 Order allow,deny
                 Allow from all
             </Directory>
      </VirtualHost>
      

1 个答案:

答案 0 :(得分:0)

集:

WSGIApplicationGroup %{GLOBAL}
在Apache配置中

这将解决Python中的第三方扩展模块的问题,这些模块不能与Python子解释器一起使用并且可能会崩溃。

如果这没有帮助,您可能会遇到导致崩溃的共享库冲突问题。

官方mod_wsgi文档中描述了这两个问题。因此,请查看mod_wsgi文档中的Frequently Asked Questions页面以获取更多链接。

相关问题