In my previous question, I asked how to make mod_wsgi use a specific Python version. Following the answer from that question, I created a Python 3.9 virtual environment and made WSGI use it. However, now my Flask app is not running at all - I just get the 404 page configured for the rest of my site. I get no errors when restarting Apache2 and the Apache error log is empty when I visit the site. I think the error must be due to my virtual environment, as I have created previous test Flask apps before using the same config style.
My virtual environment is located in path/to/my/app/venv/
.
path/to/my/app/runner.wsgi
:
import sys
# Make something appear in error log if the WSGI is run at all
raise ValueError()
PROJECT_DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, PROJECT_DIR)
from my_app import app as application
Part of /etc/apache2/sites-available/000-default-le-ssl.conf
:
WSGIDaemonProcess myapp user=www-data group=www-data threads=4 python-home=/path/to/my/app/venv/
WSGIScriptAlias /my-app/ path/to/my/app/runner.wsgi
/etc/apache2/mods-available/wsgi.load
LoadModule wsgi_module "/path/to/my/app/venv/lib/python3.9/site-packages/mod_wsgi/server/mod_wsgi-py39.cpython-39-x86_64-linux-gnu.so"
WSGIPythonHome "path/to/my/app/venv"
OS: Ubuntu 18.04.5 LTS