If your Apache config file still has:
LoadModule wsgi_module modules/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so
in it, then you likely still have the system package for mod_wsgi installed.
You can't use both at the same time and if it is for a different Python version
than your virtual environment it can fail in the way shown.
You can also have it fail as you see when the Apache user cannot access inside
your home directory because of filesystem permissions of SELinux.
It is better to not have the virtual environment and project code under your
home directory, but under /var/www or other location that Apache does have
access to.
Graham
> On 26 Jan 2021, at 4:16 am, [email protected] <[email protected]> wrote:
>
> Hello All,
>
> I am setting up a new web server using the following:
> (venv) [dev_user@96f98ccbad74 ~]$ pip freeze
> asgiref==3.3.1
> Django==3.1.5
> mod-wsgi==4.7.1
> pytz==2020.5
> sqlparse==0.4.1
>
> (venv) [dev_user@96f98ccbad74 ~]$ python --version
> Python 3.6.8
>
> (venv) [dev_user@96f98ccbad74 ~]$ httpd -v
> Server version: Apache/2.4.6 (CentOS)
>
> I used the following command to place the mod_wsgi module from 4.7.1 into the
> modules directory in the apache directory:
> mod_wsgi-express install-module
>
> Which resulted in this output:
> LoadModule wsgi_module
> "/home/dev_user/venv/lib64/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"
> WSGIPythonHome "/home/dev_user/venv"
>
> I removed the "" and placed those two lines in my httpd.conf file with some
> other lines as well:
> LoadModule wsgi_module modules/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so
>
> WSGIScriptAlias / /home/dev_user/integra/integra/wsgi.py
> WSGIPythonHome /home/dev_user/venv
> WSGIPythonPath /home/dev_user/integra
>
> #IncludeOptional conf.d/*.conf
>
> <Directory /home/dev_user/integra/integra>
> <Files wsgi.py>
> Require all granted
> </Files>
> </Directory>
>
> Directory structure
> (venv) [dev_user@96f98ccbad74 home]$ ls dev_user
> integra venv
> (venv) [dev_user@96f98ccbad74 home]$ ls dev_user/integra
> core integra manage.py
> (venv) [dev_user@96f98ccbad74 home]$ ls dev_user/integra/integra
> asgi.py __init__.py settings.py urls.py wsgi.py
>
> I'm not sure what I am missing but I cannot reach my site and the error in
> the log file is:
> [Mon Jan 25 17:25:07.931962 2021] [:info] [pid 50384] mod_wsgi (pid=50384):
> Python home /home/dev_user/venv.
> [Mon Jan 25 17:25:07.931997 2021] [:info] [pid 50384] mod_wsgi (pid=50384):
> Initializing Python.
> ImportError: No module named site
> ImportError: No module named site
> ImportError: No module named site
>
> Thank you for the help in advance!
>
> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/modwsgi/63e157e4-be6b-4106-b5d0-5ea65baae75an%40googlegroups.com
>
> <https://groups.google.com/d/msgid/modwsgi/63e157e4-be6b-4106-b5d0-5ea65baae75an%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/modwsgi/CA41565E-8BBC-4DCC-B621-FDC875C3C4ED%40gmail.com.