2

I created a one file Flask app so I can test how to deploy it on apache2 server. I followed the steps on the Flask as far as the server and WSGI configuration goes. When I point to the resource in the browser it says I have no permissions. WSGI daemon is given the same permissions as the Flask app. Below is the VirtualHost configuration.

<VirtualHost *:80>

ServerName localhost 

WSGIDaemonProcess flask_test user=someuser group=someuser threads=5
WSGIScriptAlias /flask_test/ /var/www/flask_test/flask_test.wsgi

DocumentRoot /var/www/flask_test/
ErrorLog /var/www/flask_test/logs/error.log

    <Directory /var/www/flask_test/>
        WSGIProcessGroup flask_test
        WSGIApplicationGroup %{GLOBAL}
        WSGIScriptReloading On
        Order deny,allow
        Deny from all
    </Directory>

</VirtualHost>

Here's the WSGI file

import sys

activate_this = '/home/someuser/pyProjects/general/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

sys.path.append('/home/someuser/pyProjects')

from general import test as application

And finally the output from error.log

[Tue Jul 31 01:51:18 2012] [error] Exception KeyError: KeyError(140345719740224,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
[Tue Jul 31 01:51:21 2012] [error] [client 108.207.222.48] client denied by server configuration: /var/www/flask_test/flask_test.wsgi
[Tue Jul 31 01:51:21 2012] [error] [client 108.207.222.48] client denied by server configuration: /var/www/flask_test/favicon.ico

EDIT: After implementing Graham Dumpleton suggestions server now returns code 500 with following error TypeError: 'module' object is not callable

2 Answers 2

3

The problem was in .wsgi file. I didn't import the app object correctly. Basically you want to make sure that app object is imported as application in your wsgi. For example from flask_test import app as application

Sign up to request clarification or add additional context in comments.

Comments

2

Generally want:

WSGIScriptAlias /flask_test/ /var/www/flask_test/flask_test.wsgi

No trailing slash on the mount point for a sub URL.

Worse is that you have:

Deny from all

So you are explicitly telling Apache to return forbidden.

You should have:

Allow from all

in that context.

1 Comment

Thanks. I applied your suggestions and it seems I'm getting closer. Now I'm getting 500 error and in error.log TypeError: 'module' object is not callable in error log. Is there a way to get more detailed output?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.