【问题标题】:Why does my .wsgi file give me Internal Server Error?为什么我的 .wsgi 文件会出现内部服务器错误?
【发布时间】:2021-08-10 14:57:37
【问题描述】:

Apache 2.4 - RHEL 8.3 (Ootpa) - Windows

我在服务器上运行 WSGI 文件时遇到问题。获取内部服务器错误。 (我是新手)

我已经安装了“python3-mod_wsgi”(据说 mod_wsgi 不适用于 windows)

检查是否工作:

root@xxx# sudo httpd -M | grep wsgi
proxy_uwsgi_module (shared)
wsgi_module (shared)

这意味着它有效(?)

我用 hello world(test_wsgi.py 脚本)示例进行了测试:

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]

哪个有效:

Image of hello world in browser

我的 conf 文件:(编辑掉 /path/)

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName my.server.name
        DocumentRoot /path/api

        WSGIScriptAlias /lisens/test_wsgi /path/api/lisens/test_wsgi.py

        WSGIScriptAlias /lisens/hello_world /path/api/lisens/hello_world.wsgi

        <Directory/path/lisens>
                AllowOverride All
                Require all granted
        </Directory>

        Alias /static /path/lisensAPI/static>
        <Directory /path/lisens/lisensAPI/static/>
                AllowOverride All
                Require all granted
        </Directory>

        LogLevel info

</VirtualHost>

但是当我试用 hello_world.wsgi 时:

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!\n'
    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)
    return [output]

我收到内部服务器错误

我正在做这个测试,以便稍后应用于我的 Flask 应用程序。

有什么想法吗?请告诉我是否需要更多信息来解决此问题。

【问题讨论】:

    标签: python-3.x windows apache2 mod-wsgi wsgi


    【解决方案1】:

    找到日志。显然字符串是错误的。在前面加了 b''。

    在这里找到答案:TypeError: sequence of byte string values expected, value of type str found

    【讨论】:

      猜你喜欢
      • 2023-04-01
      • 1970-01-01
      • 2015-04-06
      • 1970-01-01
      • 1970-01-01
      • 2021-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多