I've provisioned a vagrant box for an app I'm building, but I'm running into trouble when trying to get Apache to serve it.
It's using a virtualenv for it's packages - right now that's just Flask and it's dependencies, and that's all working fine. I can SSH in and run the app within the env. The app itself is just the minimal application for now.
Apache error
[Sun Mar 31 10:06:54 2013] [error] [client 10.0.2.2] mod_wsgi (pid=1587): Exception occurred processing WSGI script '/vagrant/myapp/myapp.wsgi'.
[Sun Mar 31 10:06:54 2013] [error] [client 10.0.2.2] TypeError: 'module' object is not callable
Files
/vagrant
├── env
└── myapp
    ├── app.py
    └── myapp.wsgi
myapp.wsgi
activate_this = '/vagrant/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
sys.path.insert(0, '/vagrant/myapp')
import app as application
Default site vhost
<VirtualHost *:80>
        WSGIDaemonProcess myapp user=www-data group=www-data threads=5
        WSGIScriptAlias / /vagrant/myapp/myapp.wsgi
        <Directory /vagrant/myapp>
                WSGIProcessGroup myapp
                WSGIApplicationGroup %{GLOBAL}
                Order deny,allow
                Allow from all
        </Directory>
        ErrorLog /var/log/apache2/error.log
</VirtualHost>
I've tried running Apache with the user and group vagrant and chowning the site-packages and app dir to www-data. I've also tried changing the WSGIDaemon user and group to vagrant.
I've tried adding the site-packages to the path, and I've tried adding __init__.py to myapp and changing myapp.wsgi to from myapp import app as application.
The app can be run with source ../env/bin/activate && python app.py.
I'm stumped.
The problem I had was in the wsgi file because I was importing the app package but not the class therein (caught out because they were named the same.)
activate_this = '/vagrant/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
sys.path.insert(0, '/vagrant/myapp')
from app import app as application
Note the final line has changed from import app as application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With