1

I am trying to serve my django project over Apache using mod_wsgi. Apache will start but my project in inaccessible. When Apache launches I see ImportError: No module named site in the log. There is also a php site being served by Apache and that is accessable. On the RHEL7 server I have python 2.7.5 AND python 3.6.8 installed, Apache 2.4 and the mod_wsgi module. The project is running in a pipenv virtual environment on django 2.2 and using python 3.6.8.

Here is my django.conf file...

<VirtualHost *:8002>
    DocumentRoot /app/eam/gaic/new_support_tools/support_tools
    ServerName [ServerName]
    WSGIScriptAlias / /app/eam/gaic/new_support_tools/support_tools/wsgi.py
    <Directory /app/eam/gaic/new_support_tools/support_tools>
        Options +ExecCGI
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>```

  • Search in the error logs with this command: grep wsgi /var/log/apache2/error.log – Lorem ipsum Aug 24 '20 at 15:28
  • `[Mon Aug 24 10:25:04.339585 2020] [mpm_prefork:notice] [pid 3803] AH00163: Apache/2.4.6 (Red Hat Enterprise Linux) PHP/7.2.32 OpenSSL/1.0.2k-fips mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations` – iNeedScissors61 Aug 24 '20 at 15:38
  • I think you got the solution now. Now you need to search for mod_wsgi packages that uses python3.6 and install the fitting version. On Redhat it's "yum list *mod_wsgi*" and then install with "yum install python36u-mod_wsgi-*" – Lorem ipsum Aug 24 '20 at 15:44
  • I also have mod_wsgi installed as a pip package. Do I even need it to be installed on the system? – iNeedScissors61 Aug 24 '20 at 17:51
  • you can give this a try: "yum install python36u-mod_wsgi.x86_64" and then "systemctl restart httpd". Yeah of yourse you need it in the system, as apache2 needs it. Currently it seems like apache2 uses a wsgi with is based on python2.7. If you only want to use pip and your virtualenv check this out: https://pypi.org/project/mod-wsgi/ Go to section"Connecting into Apache Installation" – Lorem ipsum Aug 24 '20 at 17:58

0 Answers0