Skip to content

Setup Lernanta Manually

Dirk Uys edited this page Jan 9, 2014 · 6 revisions

Manual Install

The main install/setup docs are based on the steps needed to install Lernanta in recent versions of Ubuntu. The easiest way is by installing Ubuntu inside virtual machine. For minimum hassles, use Ubuntu 12.04 Server (32-bit). Other versions should also work, but support is a little easier if we all use the same version. If you use another OS, make sure that you have python version 2.7.x

For install instructions on other environments look for more documentation in our wiki or contact us at the p2pu-dev mailing list.

Setting up a virtual machine

To set up a virtual machine, you can use Virtualbox. Virtualbox runs on Linux, Windows, OS X and Solaris. Use your distribution's package manager to install Virtualbox if you are running Linux. If you are running Windows, download Virtualbox from the website and follow these instructions.

Please note: There is a bug with Virtualbox on OSX when using NAT networking in an Ubuntu virtual machine. It will crash when trying to install python-memcached. Use any of the other networking options to avoid this.

Downloading the source code

If you just want to test Lernanta, you can download the latest code. If you are also going to contribute with fixes or the development of new features, please start the setup of you development environment by:

To be sure you have all the latest files, you may want to also run:

cd lernanta
git remote add upstream git://github.com/p2pu/lernanta.git
git fetch upstream
git submodule update --init --recursive

Downloading and Installing External Dependencies

The next step is to download and install Lernanta's external dependencies which varies depending on the OS you are using. The following are instructions for the latest versions of Ubuntu (please note that your system must be updated before following these instructions). If you are running another OS please look for instructions in other pages of our wiki or contact us at the p2pu-dev mailing list.

You need a few libraries and can grab them with these commands (the last two lines are needed for using sqlite, check other install pages for how to use lernanta with other db backends):

sudo apt-get install python-dev
sudo apt-get install python-setuptools
sudo apt-get install python-lxml
sudo apt-get install libssl-dev
sudo apt-get install python-imaging
sudo apt-get install python-m2crypto
sudo apt-get install gettext python-iso8601
sudo apt-get install make
sudo apt-get install swig

sudo apt-get install sqlite3
sudo apt-get install python-pysqlite2

Next, you'll need to install virtualenv, pip and virtualenvwrapper. They will allow you to install the rest of the external dependencies in an isolated Python environment. If you want to install the dependencies directly in your computer (not recommended for development) you will only need pip (remember to use sudo to install all the dependencies if this is the case).

sudo easy_install virtualenv
sudo easy_install pip
sudo pip install virtualenvwrapper

In order to configure virtualenvwrapper add the following lines to the ~/.bashrc file in your home directory.

export WORKON_HOME=$HOME/.virtualenvs
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
source /usr/local/bin/virtualenvwrapper.sh

You need to run those lines at least once by either typing them directly on the shell or by running:

bash

Now you can create the virtual environment by running:

mkvirtualenv lernanta --system-site-packages

You will notice that the shell prompt now includes the name of the virtual environment (called lernanta in this example) so you know you are working in it. In the future, when you need to use the already created virtual environment in another shell, you can run:

workon lernanta

To install the dependencies needed to use lernanta you can run:

pip install -r lernanta/lernanta/requirements/prod.txt

Other dependencies necessary for the development of lernanta can be installed by running:

pip install -r lernanta/lernanta/requirements/dev.txt

Configuring/Setting-Up Lernanta

In order to configure lernanta, please copy the configuration template and edit it to modify the database parameters and other settings (by default sqlite will be used so remember to edit this file if you are going to work with another of the database backends mentioned in our documentation). You can copy the template by running:

cp lernanta/lernanta/settings_local.dist.py lernanta/lernanta/settings_local.py

You must generate a new secret key for your lernanta setup. You can create a new key to assign to the SECRET_KEY variable in settings_local.py by running the following lines in the [django shell]

To start the shell, run this from within the lernanta folder:

 python manage.py shell

(https://docs.djangoproject.com/en/dev/ref/django-admin/#shell):

import random
allowed_chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
print ''.join([random.choice(allowed_chars) for i in range(50)])

Now use this key in your settings file for the value of SECRET_KEY

Create Database

After configuring lernanta the next step is to create the database used by it. If you use the default configuration, you will just need to create a lernanta.db database file by running:

make syncdb

Running Lernanta

Finally, start the development server by running the following line, and to take it for a spin by opening http://localhost:8000 in your browser.

python manage.py runserver

In order for the server to be accessible from another computer you can run the following line instead:

python manage.py runserver 0.0.0.0:8000

When you are trying out lernanta remember that (unless you change the configuration) emails will be printed in the shell where you ran the previous command. If you need to copy an url from these emails, be careful to removed any "=" symbols that may be added at the end of a line when the emails are displayed in the shell (e.g., remove the "=" from the url in the finish registration email which can cause a 404 page to be displayed).

Trouble Shooting

If you are new to virtual env the following videos could be of help: Python Dev Environment Screencasts.

If you follow this instructions and get an 'ImportError: No module named Image' try deleting your virtual environment, and created a new one, this time with the flag --no-site-packages. In the new environment install these packages with pip:

lxml
pil
m2crypto
iso8600

For more troubleshooting advice check out this thread in P2PU.

Clone this wiki locally