Running KOLIBRI on a Apache Vitual host

Dear All
I have a server running Apache webserver. This server is running on a private network (192.168.0.100)
I am using apache private dns/
/etc/apache2/sites-enabled
/etc/apache2/sites-available
I need to direct users to a Server-name for Kolibri

ServerName www.kolibri.freeedu.com
ServerAlias kolibri.freeedu.com
DocumentRoot “/www/domain/point-to-kobri-start-up-page/” --Point to Kolibri root document.

Where in the installation folder should I do this?
Is Kolibri running DJango?

Thanks
Edwin

Dear Edwin,

Yes, Kolibri is a Django project. Actually, it is running its own stand-alone HTTP server (CherryPy), so you can also configure your virtual host as a proxy in front of Kolibri serving some other port. See: https://httpd.apache.org/docs/2.4/vhosts/examples.html#proxy

If you are interested in running Kolibri as a Python application in an application server (how Django projects are typically run on web servers), I would recommend the most popular configuration Nginx+uWSGI. We are planning to support this directly through Debian packages that install and configure such environments.

If you are following in online tutorial (such as this one), please note that Kolibri is already a “Django project”, so you don’t need to create anything Django-wise. You need to configure the uWSGI instance in some particular aspects (same goes for any likewise app server)

  1. For the right path environment (adding e.g. /usr/lib/python3.5/site-packages/kolibri/dist)
  2. Using the Django settings module kolibri.deployment.default.settings.base
  3. Setting the URL /static to point to /home/<user>/.kolibri/static/

It takes some time to get these right… start uWSGI => read errors in logs => fix them => repeat

One last note: No one has been in actively engaged in this yet.

1 Like

Hi Benjamin
Thanks for speedy response.
I have some skills I would love to offer… If you guys needs help.
Once I have the time. I will do some small tutorial on how to combine the Apache and Cherrypy for other users. I appreiciate the effort you guys are putting into this project.

Thumps up.

Regards
Edwin

1 Like

That sounds really wonderful, thanks!! :slight_smile:

We will likely add a special section in the user docs called something like “deployment”, where technical guides can live. For instance for configuring Apache on a specific platform.

Hi Benjamin
I tried the DO tutorial.
It recommends a quick hack to check the environment:

We can quickly test this application server by passing it the information for one of our sites. For instance, we can tell it to serve our first project by typing:

uwsgi --http :8080 --home /home/user/Env/firstsite --chdir /home/user/firstsite -w firstsite.wsgi

I tried

uwsgi --http :8080 --home /opt/kolibri/kolibri-venv -chdir/opt/kolibri/kolibri-venv -w wsgi.py

But --home turned out to be not a valid parameter

Without that parameter I get:
$ uwsgi --http :8080 --chdir /opt/kolibri/kolibri-venv wsgi.py
unable to load configuration from wsgi.py

I understand “No one has been in actively engaged in this yet.”. However, some of us are trying to implement for large numbers of students on decent servers as opposed to Windowz for 20 users. Therefore any pointers would be kind of you. Not sure which would be the wsgi.py to try:

$ find . -name wsgi.py
./kolibri-venv/lib/python3.6/site-packages/kolibri/dist/django/core/handlers/wsgi.py
./kolibri-venv/lib/python3.6/site-packages/kolibri/dist/django/core/wsgi.py
./kolibri-venv/lib/python3.6/site-packages/kolibri/dist/morango/wsgi.py
./kolibri-venv/lib/python3.6/site-packages/kolibri/deployment/default/wsgi.py
./.pex/install/kolibri-0.7.0-py2.py3-none-any.whl.cf9ae904b8e7982564468df72f83e26182bb3a19/kolibri-0.7.0-py2.py3-none-any.whl/kolibri/dist/django/core/handlers/wsgi.py
./.pex/install/kolibri-0.7.0-py2.py3-none-any.whl.cf9ae904b8e7982564468df72f83e26182bb3a19/kolibri-0.7.0-py2.py3-none-any.whl/kolibri/dist/django/core/wsgi.py
./.pex/install/kolibri-0.7.0-py2.py3-none-any.whl.cf9ae904b8e7982564468df72f83e26182bb3a19/kolibri-0.7.0-py2.py3-none-any.whl/kolibri/dist/morango/wsgi.py
./.pex/install/kolibri-0.7.0-py2.py3-none-any.whl.cf9ae904b8e7982564468df72f83e26182bb3a19/kolibri-0.7.0-py2.py3-none-any.whl/kolibri/deployment/default/wsgi.py
./.pex/install/kolibri-0.7.1-py2.py3-none-any.whl.b00967505654635f22de3d8640efe8d6cba714f6/kolibri-0.7.1-py2.py3-none-any.whl/kolibri/dist/django/core/handlers/wsgi.py
./.pex/install/kolibri-0.7.1-py2.py3-none-any.whl.b00967505654635f22de3d8640efe8d6cba714f6/kolibri-0.7.1-py2.py3-none-any.whl/kolibri/dist/django/core/wsgi.py
./.pex/install/kolibri-0.7.1-py2.py3-none-any.whl.b00967505654635f22de3d8640efe8d6cba714f6/kolibri-0.7.1-py2.py3-none-any.whl/kolibri/dist/morango/wsgi.py
./.pex/install/kolibri-0.7.1-py2.py3-none-any.whl.b00967505654635f22de3d8640efe8d6cba714f6/kolibri-0.7.1-py2.py3-none-any.whl/kolibri/deployment/default/wsgi.py

Hi @nobicycle

The command line has to have --plugin python[3] specified such that the python or python3 plugin is loaded. The --home is a parameter specific to this plugin.

The file kolibri/deployment/default/wsgi.py, is what we have provided for default deployments. Basically, specify --chdir to any CWD that you need and put kolibri.deployment.default.wsgi as the module to use. For instance:

uwsgi --plugin python3 --module kolibri.deployment.default.wsgi [...]

I understand “No one has been in actively engaged in this yet.”. However, some of us are trying to implement for large numbers of students on decent servers as opposed to Windowz for 20 users. Therefore any pointers would be kind of you.

You can follow advice for generic uWSGI + Nginx deployments. This is really the best advice that I can give you right now, such that I don’t pretend that I can duplicate the vastness of experience that you can find out there :slight_smile: But also because we simply don’t have specific advice to share on uWSGI deployments with Kolibri right now. But I can definitely recommend this approach as it’s the most popular and (AFAIK) most stable and configurable Python application server that you can find!

Forwarding port 80 to 8080

If you just want Kolibri to run on Port 80, you can also setup a local iptables rule on your server. It’s easier and more efficient than Nginx as a pure proxy.

For outside connections to access your port 80:

sudo iptables -t nat -I PREROUTING --src 0/0 --dst 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports 8080

For local connections to access your port 80 (accessing localhost:80)

sudo iptables -t nat -I OUTPUT --src 0/0 --dst 127.0.0.1. -p tcp --dport 80 -j REDIRECT --to-ports 8080

To read more: https://wiki.debian.org/Firewalls-local-port-redirection

To make these rules rules persist when the server reboots, add them for instance in /etc/rc.local (without the sudo in front)