Search code examples
pythonapacheredhatmod-wsgi

Apache server mod_wsgi in Redhat gives 500 error


I have a python app that will handle HTTP responses and requests from html forms served up by an apache webserver on RedHat. My problem is that I cannot seem to find the cause of a 500 Interval Server Error I have double and triple checked all the file's permissions with no luck. I have tried changing things in the default.conf file but I don't really know what I should be messing with there. The worst part of all this is that I had this all working perfectly until a few days ago when my virtual machine I was doing all this on just randomly died on me. Now I can't remember what I did to get it to work correctly.

Here's my VirtualHost conf file:

<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>

And my /etc/httpd/logs/error_log output:

[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'

Solution

  • For anyone who may find this, the problem I was having ended up being SELinux blocking my Postgresql connection in my Python script. I had to edit the logging level of my /etc/httpd/conf/httpd.conf file to debug before I saw what the underlying error was.