Run mod_wsgi with virtualenv or Python with version different that system default Run mod_wsgi with virtualenv or Python with version different that system default flask flask

Run mod_wsgi with virtualenv or Python with version different that system default


You have to add the following line in your apache.conf in order to give the right executable and the path to the virtualenv.

WSGIPythonHome /usr/local/binWSGIPythonPath /home/fenikso/virtualenv/lib/python3.4/site-packages

You will find all the options of these two command in the mod_wsgi documentation

Be aware that you must have the version of mod_wsgi compatible with the python executable. In your case, you probably have to install mod_wsgi3.4 and configure apache to use it instead of the standart mod_wsgi module.

The whole configuration file should be :

WSGIPythonHome "/usr/local/bin"WSGIPythonPath "/home/fenikso/virtualenv/lib/python3.4/site-packages"<VirtualHost *:80>        ServerName album2.site.cz        Alias /static "/home/fenikso/Album/static"        Alias /photos "/home/fenikso/Album/photos"        Alias /thumbs "/home/fenikso/Album/thumbs"        WSGIScriptAlias / "/home/fenikso/Album/wsgi.py"        <Directory "/home/fenikso/Album">            AllowOverride None            Allow from all        </Directory>        <Directory "/home/fenikso/Album/static">            AllowOverride None            Allow from all        </Directory>        <Directory "/home/fenikso/Album/photos">            AllowOverride None            Allow from all        </Directory>        <Directory "/home/fenikso/Album/thumbs">            AllowOverride None            Allow from all        </Directory></VirtualHost>


Look into the WSGIPythonHome and WSGIPythonPath directives. It's also possible that you have a python2.6 mod_wsgi installed, mod_wsgi must be compiled for the intended python version and does not support multiple python versions. So check that your mod_wsgi is py3.4 compatible and set the directives above.

Alternatively, you could run the flask app with a python server like gunicorn and proxypass from apache to gunicorn.