I am trying to get my Apache Web Server to run my Django page using wsgi.py. My virtual environment is at /var/www/myapp/myapp_root/myapp. When I activate the virtual environment I see my user home directory being used. I tried the following wsgi.py changes:
"""
WSGI config for trackx project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
"""
import os,sys
sys.path.append('/home/myuserid/.local/share/virtualenvs/lib/python3.9/site-packages')
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'trackx.settings')
application = get_wsgi_application()
When I try to start the server - it gives me the following repeating error (over and over):
Python path configuration:
PYTHONHOME = '/home/myuser/.local/share/virtualenvs/myapp-nygxcPTP/lib/python3.9'
PYTHONPATH = (not set)
program name = 'python3'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '/usr/local/bin/python3'
sys.base_prefix = '/home/myuser/.local/share/virtualenvs/myapp-nygxcPTP/lib/python3.9'
sys.base_exec_prefix = '/home/myuser/.local/share/virtualenvs/myapp-nygxcPTP/lib/python3.9'
sys.executable = '/usr/local/bin/python3'
sys.prefix = '/home/myuser/.local/share/virtualenvs/myapp-nygxcPTP/lib/python3.9'
sys.exec_prefix = '/home/myuser/.local/share/virtualenvs/myapp-nygxcPTP/lib/python3.9'
sys.path = [
'/home/my-user/.local/share/virtualenvs/myapp-nygxcPTP/lib/python3.9/lib64/python38.zip',
'/home/myuser/.local/share/virtualenvs/myapp-nygxcPTP/lib/python3.9/lib64/python3.8',
'/home/myuser/.local/share/virtualenvs/myapp-nygxcPTP/lib/python3.9/lib64/python3.8/lib-dynload',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f52bfd07880 (most recent call first):
<no Python frame>
My WSGI settings in the http.conf file look like this...
WSGIPythonHome /var/www/myapp/myapp_root/venv
WSGIPythonPath /var/www/myapp/myapp_root/venv/lib/python3.9/site-packages
WSGIDaemonProcess myapp python-home=/home/myuser/.local/share/virtualenvs/myapp-nygxcPTP/lib/python3.9
WSGIProcessGroup myapp
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /var/www/myapp/myapp_root/myapp/wsgi.py
<Directory /var/www/myapp/myapp_root/myapp>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
Anyone run into this error - any ideas would be great. Have tried changing some of the settings to my actual .local directories in the http configuration, but that seems to create permission errors, and then I still get the same repeating error results.