[Flask] Deploying on httpd and mod_wsgi

Craig Amundsen amundsen.craig at gene.com
Thu Sep 22 16:28:25 EDT 2016

Thanks for all the suggestions. In order to let the internet remember this
for me, here's what worked. In the mod_wsgi docs there's a throwaway line
about if you don't have a factory method put "from app import app as

The example app you build in the Grinberg book does have you implement a
factory method. This .wsgi file worked for me:

import os
import sys

sys.path.insert(0, "/var/www/CraigsApplication")

from app import create_app
application = create_app(os.getenv('FLASK_CONFIG') or 'default')

Thanks for the prompting about using a virtualenv. I'm not using one and
that's my next stumbling block. I don't have root on this machine and I
didn't want to use the system python, so I built my own more current
python. In my .bashrc I have ensured that the path to my custom python is
before /usr/bin so when I log in I get the correct python. Apache/mod_wsgi,
though, are using /usr/bin/python which doesn't have any of the
Flask-required libraries.

Can anyone tell me how I force it to use a non-default python?

- Craig

On Thu, Sep 22, 2016 at 1:20 PM, Alex Alex <alex-alex-90 at wp.pl> wrote:

> Hi,
> I'm not an expert on mod_wsgi and Apache. In fact I've used it many years
> ago for the last time.
> Are you sure your imports are fine? The error says that you are missing
> LCD module - probably it is installed on your laptop but not the on the
> server. Without seeing your requirements.txt and flask app imports I guess
> it will be hard to say something more.
> As for Apache unless you have some special requirements you may want to
> check out gunicorn - it works nicely with flask applications and is python
> based. That is how I run test instances on Heroku actually.
> Cheers
> Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160922/87e511aa/attachment.html>

More information about the Flask mailing list