Question

I am set up Flask, a python web micro-framework under apache with mod_wsgi.

The application works fine except python confparser. This throws no error :

parser = ConfigParser.ConfigParser()
parser.read('snati.con')

But when I add :

parser.get('database', 'user')

I got internal server error without anything in the error.log of Apache

I tried also :

file = open("sample.txt")

Same result.

There must be some configuration issues but I can't find it.

My apache conf looks like :

WSGIRestrictStdout Off

<VirtualHost *:80>
    ServerName my.com

    WSGIDaemonProcess myapp user=me group=me threads=5

    WSGIScriptAlias / /home/me/www/myapp.wsgi

    <Directory /home/me/www/myapp >
        WSGIProcessGroup myapp
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

My app.wsgi

#active the python virtualenv for this application
activate_this = '/home/gilles/www/snati/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))


import sys
sys.path.insert(0, '/home/gilles/www/snati/src')
sys.stdout = sys.stderr

from app import app as application

What can possibly be wrong and why can I not get the error in Apache log?

Was it helpful?

Solution

Use absolute paths to files in your Python code, not relative paths.

The current working directory of the process will not be where your application code and files is.

You are not seeing any errors as Flask will not log them if not in debug mode. Setup application to capture them and email them or otherwise record them some how. I don't remember what options Flask has for the latter.

OTHER TIPS

Add the path to you apache setting file with a home variable

WSGIDaemonProcess myapp user=me group=me threads=5 home=/path/to/your/directory

this changes the working directory for the process.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top