Skip to content

Deployment using Apache WSGI

Fabian Reinders edited this page Oct 24, 2021 · 1 revision

Deploying BeeLogger using Apache and WSGI

Installing packages

These packages are needed sudo apt install git python3 python3-pip python3-dev

Setting up WSGI

I this case we will use Apache2 in combination with Python3.7 and mod_wsgi (pip)

So let's install the things

sudo apt install apache2 apache2-dev libapache2-mod-wsgi-py3

python3 -m pip install mod_wsgi pymysql

Now modify your apache2.conf with sudo nano /etc/apache2/apache2.conf

Add this at the bottom:

LoadModule wsgi_module /usr/local/lib/python3.7/dist-packages/mod_wsgi/server/mod_wsgi-py37.cpython-37m-arm-linux-gnueabihf.so
WSGIPythonHome "/usr"

If you use a different Python version, change the Path accordingly.

Now configure your virtual host: sudo nano /etc/apache2/sites-available/000-default.conf

And change it to this:

<VirtualHost *:80>
    WSGIDaemonProcess beelogger threads=5 lang='de_DE.UTF-8' locale='de_DE.UTF-8'
    WSGIScriptAlias / /var/www/BeeLogger/wsgi/beelogger.wsgi

    <Directory /var/www/BeeLogger>
        WSGIProcessGroup beelogger
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

Cloning BeeLogger

cd /var/www git clone https://github.com/Programmier-AG/BeeLogger

Don't forget to set the permissions! Don't forget to rename the example_config to config and fill in the data!

Finally restart Apache: sudo service apache2 restart

Setting up database

Install MySql server and client.

sudo apt install mariadb-server mariadb-client

Launch the admin panel of your choice or do the following in the console:

  • Add a database
  • Add a table into that database
  • Create an user
  • Grant the user permission on the db

The table should look like this:

Field name Type Allow nulls Key Default Value Extras
number bigint No primary NULL auto_increment
temperature double Yes None NULL -
weight double Yes None NULL -
humidity double Yes None NULL -
measured datetime Yes None NULL -

Also create a table for statistics:

Field name Type Allow nulls Key Default Value Extras
id tinyint No primary NULL auto_increment
data_calls int Yes None NULL -
insert_calls double Yes None NULL -
website double Yes None NULL -

You can also create the database with the included sql file.

You are ready to go!