FlaskBB
A lightweight forum software in Flask
Member
Joined:
Posts: 2

Hello,
As I am using Apache, I had to figure out how to configure it to work with flaskbb. So here are the two config files that you need
First, modify the file wsgi.py to :

import os
activate_this = '/home/www/flaskbb/venv/bin/activate_this.py'
with open(activate_this) as file_:
    exec(file_.read(), dict(__file__=activate_this))
import sys

sys.path.insert(0, '/home/www')
sys.path.insert(0, '/home/www/flaskbb')

from flaskbb import create_app
from flaskbb.utils.helpers import ReverseProxyPathFix

_basepath = os.path.dirname(os.path.abspath(__file__))

# will throw an error if the config doesn't exist
#flaskbb = create_app(config='flaskbb.cfg')
application = create_app('/home/www/flaskbb/flaskbb.cfg')

#  Uncomment to use the middleware
#flaskbb.wsgi_app = ReverseProxyPathFix(flaskbb.wsgi_app)

this assumes that you have clone flaskbb into /home/www and that you have created your virtualenv into that directory

Secondly, create a conf (ie : 020-flaskbb.conf) file into your Apache conf directory (probably /etc/apache2/sites-avaible) with :

<VirtualHost *:80>
    ServerName forum.mysite.com
    DocumentRoot  "/home/www"
    WSGIDaemonProcess flaskbb processes=2 threads=2 display-name=%{GROUP} python-home=/home/www/flaskbb/venv
    WSGIProcessGroup flaskbb
    WSGIScriptAlias / /home/www/flaskbb/wsgi.py process-group=flaskbb application-group=%{GLOBAL}
    Alias /static/ /home/www/flaskbb/flaskbb/static/

    <Directory /home/www/flaskbb/>
        Require all granted
        WSGIProcessGroup flaskbb
        WSGIApplicationGroup %{GLOBAL}
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
<VirtualHost *:443>
    ServerName forum.mysite.com
    DocumentRoot  "/home/www"
    WSGIDaemonProcess flaskbbs processes=2 threads=2 display-name=%{GROUP} python-home=/home/www/flaskbb/venv
    WSGIProcessGroup flaskbbs
    WSGIScriptAlias / /home/www/flaskbb/wsgi.py process-group=flaskbbs application-group=%{GLOBAL}
    Alias /static/ /home/www/flaskbb/flaskbb/static/

    WSGIPassAuthorization On

    <Directory /home/www/flaskbb/>
        Require all granted
        WSGIProcessGroup flaskbbs
        WSGIApplicationGroup %{GLOBAL}
        Order allow,deny
        Allow from all
    </Directory>
    #   SSL Engine Switch:
    #   Enable/Disable SSL for this virtual host.
    SSLEngine on

    #   A self-signed (snakeoil) certificate can be created by installing
    #   the ssl-cert package. See
    #   /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
    #   If both key and certificate are stored in the same file, only the
    #   SSLCertificateFile directive is needed.
    SSLCertificateFile    /etc/ssl/server.crt
    SSLCertificateKeyFile /etc/ssl/server.key

</VirtualHost>

Create a link to that file in the directory /etc/apache2/sites-enabled with the command

ln -s ../sites-avaible/020-flaskbb.conf .

Reload the apache config with the commande

service apache2 reload

Now point your browser on your url (ie. http://forum.mysite.com) and you should land on your forum.

Hoping it helps

Member
avatar
Joined:
Posts: 8

instead of /etc/apache2/sites-avaible it is /etc/httpd/httpd.conf here

to not insult the real apache indians

enter image description here