I'm trying to run a really simple Python web application developed with the Flask microframework. I'm on a VPS with Ubuntu 10.04 LTS. I've followed this instructions in order to get the comforting "Hello world!", and it was a successful experience. But now, I'm setting up a slightly more complicated configuration and I cannot get this to work properly.
The Apache Virtual Host configuration for my application is:
<VirtualHost *:80>
ServerAdmin user@example.org
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /srv/www/domain.com/public_html/
LogLevel info # I've put this for debugging purposes.
ErrorLog /srv/www/domain.com/logs/error.log
CustomLog /srv/www/domain.com/logs/access.log combined
WSGIDaemonProcess username user=username group=username threads=5 processes=5
WSGIScriptAlias /myapplication/ /srv/www/domain.com/myapplication/myapplication.wsgi
<Directory /srv/www/domain.com/myapplication/myapplication>
WSGIProcessGroup username
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
Alias /css /srv/www/domain.com/public_html/css
Alias /js /srv/www/domain.com/public_html/js
Alias /images /srv/www/domain.com/public_html/images
</VirtualHost>
And my WSGI configuration file is:
# -*- coding: utf-8 -*-
from myapplication import app as application
Is this something wrong with the above configurations?
Finally, Apache gives me a 500 error page. So I check the logs:
[info] mod_wsgi (pid=3132, process='', application='domain.com|/myapplication/'): Loading WSGI script '/srv/www/domain.com/myapplication/myapplication.wsgi'.
[error] mod_wsgi (pid=3132): Target WSGI script '/srv/www/domain.com/myapplication/myapplication.wsgi' cannot be loaded as Python module.
[error] mod_wsgi (pid=3132): Exception occurred processing WSGI script '/srv/www/domain.com/myapplication/myapplication.wsgi'.
[error] Traceback (most recent call last):
[error] File "/srv/www/domain.com/myapplication/myapplication.wsgi", line 3, in <module>
[error] from myapplication import app as application
[error] ImportError: No module named myapplication
The tree structure resembles this:
/myapplication
myapplication.wsgi
myapplication (python package)
Apparently, Python couldn't find the myapplication
module in sys.path
. But I've checked with prints and it's right there. I know this issue might be trivial to resolve, but I'm a little confused. How could I get in the right direction to solve this?