dternyak/React-Redux-Flask

Apache2 Deployment

kylefrost opened this issue · 1 comments

I'm trying to figure out how I would deploy this under Apache2. I've deployed Flask apps in the past, but that was using the regular Jinja frontend, not a React frontend (this is my first React app). Any pointers on how this would be done?

Got it! In case anyone is interested, I did this as my Virtual Host:

# React-Redux-Flask Apache2 Configuration

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com

    WSGIDaemonProcess example.com python-home=/var/www/example.com/venv python-path=/var/www/example.com
    WSGIProcessGroup example.com

    WSGIScriptAlias / /var/www/example.com/app.wsgi process-group=example.com

    <Directory /var/www/example.com >
        <Files app.wsgi>
            Require all granted
        </Files>
    </Directory>

    WSGIPassAuthorization On

    # Not sure if needed but it works so I'm not touching it
    <Directory /var/www/example.com >
        Require all granted
    </Directory>
</VirtualHost>

and here is my app.wsgi:

import os, sys

PROJECT_DIR = '/var/www/example.com'
sys.path.insert(0, PROJECT_DIR)

def execfile(filename):
    globals = dict(__file__=filename)
    exec(open(filename).read(), globals)

activate_this = os.path.join(PROJECT_DIR, 'venv/bin', 'activate_this.py')
execfile(activate_this)

from application.app import app as application