Wsgi process not loading the correct python environment
Unfortunately no relevant help found so far - even if a lot of similar questions have been raised.
I had an issue with configuring 2 separate django projects on the same server, where I can't use subdomains. This lead me to Multiple mod_wsgi apps on one virtual host directing to wrong app which helped by utilizing the <location>
tag to get closer to a solution.
Here's the remaining problem:
I have configured 1 virutal host with ssl and 2 different "sites":
<VirtualHost *:443>
ServerName myserver.com
SSLEngine on
SSLCertificateFile /etc/httpd/ssl/myserver.com.crt
SSLCertificateKeyFile /etc/httpd/ssl/myserver.com.key
SSLCACertificateFile /etc/httpd/ssl/myserver.com.bundle
# anspl4fd configuration
Alias /anspl4fd/static/ /var/customers/webs/anspl4fd/static/
<Directory /var/customers/webs/anspl4fd/static>
Require all granted
</Directory>
WSGIDaemonProcess anspl4fd python-home=/var/customers/python-env/anspl4fd python-path=/var/customers/webs/anspl4fd
WSGIScriptAlias /anspl4fd /var/customers/webs/anspl4fd/Webseite/wsgi.py
<Location /anspl4fd>
WSGIProcessGroup anspl4fd
</Location>
<Directory /var/customers/webs/anspl4fd/Webseite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
# anscrd configuration
Alias /anscrd/static/ /var/customers/webs/anscrd/static/
<Directory /var/customers/webs/anscrd/static>
Require all granted
</Directory>
WSGIScriptAlias /anscrd /var/customers/webs/anscrd/Webseite/wsgi.py
WSGIDaemonProcess anscrd python-home=/var/customers/python-env/anscrd python-path=/var/customers/webs/anscrd
<Location /ancrd>
WSGIProcessGroup anscrd
</Location>
<Directory /var/customers/webs/anscrd/Webseite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
But, the 2nd site configuration "anscrd" doesn't work off the correct python-environment. It uses the system default, verified by executing:
sys.stderr.write(f"Python executable: {sys.executable}\n")
sys.stderr.write(f"Python version: {sys.version}\n")
sys.stderr.write(f"Python path: {sys.path}\n")
in my "sites" wsgi.py
Now, adding:
sys.path.insert(0, '/var/customers/webs/anscrd') # Project directory
sys.path.insert(0, '/var/customers/python-env/anscrd/lib/python3.9/site-packages')
to that same wsgi.py would "fix" / workaround that problem and both "sites" (django projects) execute exactly as they're supposed to.
But I'd much rather know why my WSGIDaemonProcess(es) are not correctly working - I am at a loss
System: Oracle Linux 9.4 Apache 2.4 Python 3.9 Django 4.2