These are outline instructions on setting up the Numbas editor with a backend MySQL database.
The Numbas editor uses Django, a web framework written in the Python programming language. Django has many configuration options, which we won't detail here. For more information, consult the Django documentation.
The following instructions are for a server running Ubuntu Xenial (16.04) or newer.
Packages that would be installed as part of a standard Ubuntu install are not listed.
apt-get
install apache2 apache2-dev git-core mysql-server
mysql-common python3 acl libmysqlclient-dev python-dev
libapache2-mod-wsgi-py3 python-tk tcl-dev tk-dev
a2enmod wsgi
Rather than rely on the packaged version of Django, a more flexible approach is to use virtualenv, which is a tool to create an isolated Python environment.
groupadd numbas
usermod your username -a -G numbas,www-data
You might need to log out and back in for the group change to take effect.
apt-get install python3-pip
pip3 install virtualenv
mkdir /opt/python
setfacl -dR -m g:numbas:rwx /opt/python
virtualenv /opt/python/numbas-editor
source /opt/python/numbas-editor/bin/activate
(This ensures that subsequent python packages are installed in this isolated environment, and not in the system environment.)
numbas_editor
:
create database numbas_editor;
numbas_editor
database, with a password of your choice:
grant all privileges on numbas_editor.* to
'numbas_editor'@'localhost' identified by 'password';
mkdir /srv/numbas
mkdir /srv/numbas/compiler
mkdir /srv/numbas/media
mkdir /srv/numbas/previews
mkdir /srv/numbas/static
cd /srv/numbas
chmod 2770 media previews
chmod 2750 compiler static
chgrp www-data compiler media previews static
setfacl -dR -m g::rwX media previews
setfacl -dR -m g::rX compiler static
git clone git://github.com/numbas/Numbas /srv/numbas/compiler
git clone git://github.com/numbas/editor /srv/www/numbas_editor
pip install -r /srv/www/numbas_editor/requirements.txt
pip install -r /srv/numbas/compiler/requirements.txt
pip install mysqlclient mod_wsgi
Run python first_setup.py
This will configure the editor based on your answers to a few questions, and write numbas/settings.py
.
If you've been following these instructions exactly, you can accept the defaults for most of the questions.
If you make any mistakes, you can run the script again, or edit numbas/settings.py
directly.
/etc/apache2/sites-available/numbas_editor.conf
with
contents similar to that in apache2_ubuntu.conf
.
If following these instructions exactly, then all that needs changing
are the lines ServerName
and ServerAdmin
.
a2ensite numbas_editor.conf
service apache2 reload
To keep the editor up to date, run the following script:
source /opt/python/numbas-editor/bin/activate
cd /srv/numbas/compiler
git pull origin master
pip install -r requirements.txt
cd /srv/www/numbas_editor
git pull origin master
python manage.py migrate
python manage.py collectstatic --noinput
pip install -r requirements.txt
touch web/django.wsgi
Note that if any changes are made to the editor code, including
editing the settings files, then for the web server to recognise these
changes you must either touch
the web/django.wsgi
file, or restart
the Apache server.