Problem: There is a similar question on Stack Overflow: "Can I deploy both Python 2 and 3 Django app with Apache using mod_wsgi?" From the answer there I know that it is possible two have multiple Django projects (written in Python 2 and 3) on one Apache server. However, I can't manage to make this work.
What I have so far:
- I'm using Linux (Debian/Ubuntu).
Three Django projects are stored in three separate Python Virtual Environments (i.e. py3venv1, py3venv2, py2venv1):
/var/www/ .........py3venv1/ <-- Python 3 venv ..................bin/ ..................include/ ..................lib/ ..................project1/ <-- Python 3 Django Project ........................../manage.py ........................../project1/wsgi.py ........................../myapp .........py3venv2/ <-- Python 3 venv ..................bin/ ..................include/ ..................lib/ ..................project2/ <-- Python 3 Django Project ........................../manage.py ........................../project2/wsgi.py ........................../myapp .........py2venv1/ <-- Python 2 venv ..................bin/ ..................include/ ..................lib/ ..................project3/ <-- Python 2 Django Project ........................../manage.py ........................../project3/wsgi.py ........................../myappI installed mod_wsgi for Python3 (
pip3 install mod_wsgi)Apache configuration:
/etc/apache2/sites-available/000-default.conffor Projects 1 and 2 (Python3 only), Project 3 (Python 2) is not configured:<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # Project 1 (Python3) WSGIScriptAlias /project1 /var/www/py3venv1/project1/project1/wsgi.py process-group=group1 WSGIDaemonProcess group1 python-home=/var/www/py3venv1/lib/python3.5 python-path=/var/www/py3venv1/project1 WSGIProcessGroup group1 Alias /project1/static /var/www/py3env1/project1/assets <Directory /var/www/py3venv1/project1/project1> <Files wsgi.py> Require all granted </Files> </Directory> # Project 2 (Python3) WSGIScriptAlias /project2 /var/www/py3venv2/project2/project2/wsgi.py process-group=group2 WSGIDaemonProcess group2 python-home=/var/www/py3venv2/lib/python3.5 python-path=/var/www/py3venv2/project2 WSGIProcessGroup group2 Alias /project2/static /var/www/py3env2/project2/assets <Directory /var/www/py3venv2/project2/project2> <Files wsgi.py> Require all granted </Files> </Directory> </VirtualHost>
Outcome: Both Python 3 projects work fine. Python 2 project does not work.
Question: How can I make all three Django projects work on Apache?