I'm running a small Django server on Ubuntu with virtualenv, apache2 and mod_wsgi.
I have virtualenv created with python3 on both windows and linux. pip --version shows:
(env)lbr@irma-fr:/var/www/irmaweb/irmaweb$ pip --version
pip 7.0.3 from /var/www/irmaweb/env/lib/python3.4/site-packages (python 3.4)
It works fine on windows, but when deploying on my Ubuntu server i get the following error:
The error is because Django create a new empty DB in /var/www instead of using the DB created by ./manage.py migrate in my project root:
(env)lbr@irma-fr:/var/www/irmaweb/irmaweb$ ls -al /var/www
total 20
drwxrws--- 5 lbr www-data 4096 Jul 1 05:58 .
drwxr-xr-x 12 root root 4096 Jun 26 09:53 ..
-rw-r--r-- 1 www-data www-data 0 Jul 1 05:58 dev.db
But I think the root of the issue is because Django get called from python2 as shown in the screenshot instead of getting called by python3 as my virtualenv is configured for.
Here is below my apache2 configuration:
(env)lbr@irma-fr:/var/www/irmaweb/irmaweb$ cat /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
WSGIDaemonProcess irmaweb python-path=/var/www/irmaweb/irmaweb:/var/www/irmaweb/env/lib/python3.4/site-packages
WSGIProcessGroup irmaweb
WSGIScriptAlias / /var/www/irmaweb/irmaweb/irmaweb/wsgi.py
Alias /site_media/static/ /var/www/irmaweb/irmaweb/irmaweb/site_media/static/
So I guess I'm missing something! how to tell apache/wsgi to call python from my virtualenv folder:
(env)lbr@irma-fr:/var/www/irmaweb$ ls -al env/bin/python*
lrwxrwxrwx 1 lbr www-data 7 Jun 30 15:19 env/bin/python -> python3
-rwxrwxr-x 1 lbr www-data 4061272 Jun 30 15:19 env/bin/python3
lrwxrwxrwx 1 lbr www-data 7 Jun 30 15:19 env/bin/python3.4 -> python3
Instead of using the system python from /usr/bin ?