1

I have created a Flask Application based on the Large Application Structure in Miguel Grinberg's Flask Web Development Book. I have followed the tutorial in how-to-deploy-a-flask-application-on-an-ubuntu-vps and have managed to deploy a single file Flask application on my server. What changes/ modifications do I have to implement to my .wsgi file and apache config to be able to host Large Structured applications?

My Apache2 .conf file:

<VirtualHost *:80>
        ServerName devrupt.com
        ServerAdmin lui@devrupt.com
        WSGIScriptAlias / /var/www/Devrupt/devrupt.wsgi
        <Directory /var/www/Devrupt/Devrupt/>
                Order allow,deny
                Allow from all
        </Directory>
        Alias /static /var/www/Devrupt/Devrupt/static
        <Directory /var/www/Devrupt/Devrupt/static/>
                Order allow,deny
                Allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

My .wsgi file:

#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/Devrupt/")

from Devrupt import app as application
application.secret_key = 'Add your secret key'
luishengjie
  • 187
  • 6
  • 15

1 Answers1

0

Try to add:

DocumentRoot /path/to/rootdir
WSGIDaemonProcess <projectname> user=flask group=www-data threads=2 home=/path/to/rootdir/project
WSGIProcessGroup <projectname>
WSGIScriptAlias / /path/to/rootdir/project/flask.wsgi

And if You're using virtualenv add this to .wsgi file:

activate_this = '/path/to/rootdir/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
Filip
  • 128
  • 5