Useful link for requirements: How To Deploy a Flask Application on an Ubuntu VPS
Under /var/www
folder you should have a structure like following
/var/www/
/var/www/project-name/
/var/www/project-name/project-name.wsgi
/var/www/project-name/project/__init__.py
/var/www/project-name/project/env
/var/www/project-name/project/...
project-name.wsgi
#!/usr/bin/python
activate_this = '/var/www/project-name/project/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/project-name/")
from project import app as application
__init__.py
... imports
from flask import Flask
# flask settings
app = Flask(__name__)
... app
if __name__ == "__main__":
app.run(threaded=True)
001-project-name.conf
<VirtualHost *:80>
ServerName api.project.me
WSGIScriptAlias / /var/www/project-name/project-name.wsgi
<Directory /var/www/project-name/project/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/project-name-error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =api.project.me
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>