Redhat 中的 Apache 服务器 mod_wsgi 出现 500 错误

Apache server mod_wsgi in Redhat gives 500 error

我有一个 python 应用程序,它将处理来自 html 表单的 HTTP 响应和请求,这些表单由 RedHat 上的 apache 网络服务器提供。我的问题是我似乎无法找到 500 Interval Server Error 的原因我已经对所有文件的权限进行了双重和三次检查,但没有成功。我试过更改 default.conf 文件中的内容,但我真的不知道我应该在那里搞砸什么。所有这一切中最糟糕的部分是,直到几天前,我的虚拟机才在我身上随机死机,直到几天前我一直在完美地工作。现在我不记得我做了什么让它正常工作。

这是我的 VirtualHost 配置文件:

<VirtualHost 172.22.2.3:80>
    ServerName www.mapzest.com
    DocumentRoot /var/www/templates 
    Redirect permanent / https://www.mapzest.com
</VirtualHost>

<VirtualHost 172.22.2.3:443>

    ServerName www.mapzest.com

    DocumentRoot /var/www/templates

    Alias /static/ /var/www/static

    SSLEngine On
    SSLCertificateFile /etc/pki/tls/certs/localhost.crt
    SSLCertificateKeyFile /etc/pki/tls/private/localhost.key

    <Directory /var/www/templates>
        Require all granted
        AllowOverride All
    </Directory>

    WSGIScriptAlias / /var/www/python/app.py

    WSGIDaemonProcess mapzest.com python-path=/usr:/var/www/python
    WSGIProcessGroup mapzest.com

    <Directory /var/www/python>
        Require all granted
    </Directory>

    <Directory /var/www/static>
        Require all granted
    </Directory>

</VirtualHost>

我的 /etc/httpd/logs/error_log 输出:

[Tue Dec 03 02:02:03.073297 2019] [core:notice] [pid 52933:tid 140480814379328] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Tue Dec 03 02:02:03.074106 2019] [suexec:notice] [pid 52933:tid 140480814379328] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Tue Dec 03 02:02:03.075278 2019] [ssl:warn] [pid 52933:tid 140480814379328] AH01909: www.mapzest.com:443:0 server certificate does NOT include an ID which matches the server name
[Tue Dec 03 02:02:03.091284 2019] [ssl:warn] [pid 52933:tid 140480814379328] AH01909: www.mapzest.com:443:0 server certificate does NOT include an ID which matches the server name
[Tue Dec 03 02:02:03.091431 2019] [lbmethod_heartbeat:notice] [pid 52933:tid 140480814379328] AH02282: No slotmem from mod_heartmonitor
[Tue Dec 03 02:02:03.094860 2019] [mpm_event:notice] [pid 52933:tid 140480814379328] AH00489: Apache/2.4.41 (Fedora) OpenSSL/1.1.1d mod_wsgi/4.6.6 Python/3.7 configured -- resuming normal operations
[Tue Dec 03 02:02:03.094880 2019] [core:notice] [pid 52933:tid 140480814379328] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

对于可能发现此问题的任何人,我最终遇到的问题是 SELinux 在我的 Python 脚本中阻止了我的 Postgresql 连接。在我看到潜在错误是什么之前,我必须将 /etc/httpd/conf/httpd.conf 文件的日志记录级别编辑为 debug