【问题标题】:Hello World using mod_wsgi, Internal error, misconfigurationHello World 使用 mod_wsgi,内部错误,配置错误
【发布时间】:2015-08-10 22:49:31
【问题描述】:

我在 Windows 上,正在尝试在 Apache 服务器上调用 mod_wsgi。我在 /usr/lib/apache2/modules/ 中找到了 mod_wsgi.so,并且我有一个名为 MyApp - /home/danu_bg/public_html/MyApp 的目录。

在这个目录中我有application.wsgi

def application(environ, start_response):
    status = '200 OK' 
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

.htaccess的配置文件是

<Directory /home/danu_bg/public_html/MyApp>
WSGIScriptAlias /home/danu_bg/public_html/MyApp/application.wsgi
Order allow,deny
Allow from all
</Directory>

我不认为我可以访问主配置文件,httpd.config 当我查看 /usr/lib/apache2/build 时,我看到 config.nice 但没有看到 httpd.config

我正在使用 WinSCP 连接到服务器,我没有 shell 访问权限。 当我转到 URL 时,我收到此错误

 Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request

【问题讨论】:

  • 您不能将 Directory/WSGIScriptAlias 放在 .htaccess 文件中。 mod_wsgi.so 在系统上是不够的,必须配置 Apache 来加载它。您确实需要从主机提供商那里了解 Apache 是否甚至被配置为加载 mod_wsgi。如果它是一个共享系统,他们不应该允许您使用 .htaccess 文件中的 mod_wsgi,因为这样做会带来安全风险,除非他们采取了特殊措施来配置 mod_wsgi 以将您的应用程序隔离到它自己的进程中。

标签: python apache .htaccess mod-wsgi


【解决方案1】:

当我查看页面时https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives

我看到WSGIScriptAlias 指令的以下语法:

WSGIScriptAlias /name /web/wsgi-scripts/name

所以该指令有两个参数:URI 和 wsgi 脚本。在您的情况下,可能类似于:

WSGIScriptAlias /app /public_html/MyApp/application.wsgi

在 /app URL 下公开您的应用程序。

【讨论】:

  • 嗨 Freek,我已经编辑了答案以包含我使用过的完整路径
猜你喜欢
  • 2010-10-20
  • 1970-01-01
  • 1970-01-01
  • 2017-03-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-09
相关资源
最近更新 更多