August 26, 2013

Installing Weblate from sources on Ubuntu 13.04 raring

Weblate is a web-based collaborative translation tool developed by Michal Čihař. Among its features includes full integration with the Git distributed version control system.

Following are the instructions to install Weblate from sources on Ubuntu 13.04 raring.

You will see highlighted the configuration settings that you should provide according to your system.

Initial server setup

We start with an empty machine with Ubuntu 13.04 installed. The first step is to update the system.

Assuming that you have a machine SSH key, open a terminal on the remote machine:

ssh -i your-machine-key-file.pem ubuntu@your-machine-public-dns

Update the package lists from the repositories and install the newest versions of the packages currently installed on the system:

sudo apt-get update
sudo apt-get upgrade

Close the remote terminal:


Reboot the machine and, once the machine has restarted, open a new terminal on the remote machine:

ssh -i your-machine-key-file.pem ubuntu@your-machine-public-dns

Install the Network Time Protocol daemon to keep the machine clock synchronized:

sudo apt-get install ntp

Install Git

Git is a distributed version control system. Weblate uses Git to manage the translation versions.

Install the Git distributed version control system:

sudo apt-get install git

Install MySQL

Weblate can operate with various database backends, we have chosen MySQL for this installation. We will install a local MySQL instance (you can also use a remote server):

sudo apt-get install mysql-server

You will be prompted for the root user password, provide one and take note:

New password for the MySQL "root" user:

Create the Weblate database and user

We will create a MySQL database and a user for Weblate, for this purpose open a MySQL shell:

mysql --user=root --password=YOUR_MYSQL_ROOT_PASSWORD

You will need to provide a password for the Weblate database user, provide one and take note. Paste the following to create the Weblate database:

USE mysql;
GRANT ALL ON weblate.* TO 'weblate'@'localhost'

Install Memcached

Memcached is a distributed memory object caching system, intended for speeding up dynamic web applications. We will install a local instance of memcached, as recommended.

sudo apt-get install memcached

Install the Apache HTTP server

Weblate is a Django web application. A Django web application normally runs behind a web server, and for this installation we have chosen the Apache HTTP server.

WSGI is a specification for web servers to communicate with Python web applications, we also install the WSGI adapter module for Apache.

sudo apt-get install apache2 libapache2-mod-wsgi

Create the Weblate system user

Create a new system user to run the Weblate application:

sudo adduser --system --group --home /var/opt/weblate \
  --gecos Weblate --shell /bin/sh weblate

Set the ownership of the weblate user home directory:

sudo chown -R weblate:weblate /var/opt/weblate

Create the directory to store the Git repositories:

sudo -u weblate mkdir /var/opt/weblate/repos

Create the directory to store the full-text indexes:

sudo -u weblate mkdir /var/opt/weblate/whoosh-index

Create a directory to store the SSH configuration and keys:

sudo -u weblate mkdir /var/opt/weblate/.ssh

Create the directory to store the log files:

sudo install --owner weblate --group weblate \
  --directory /var/log/weblate

Install the Weblate requirements

Install additional build dependencies:

sudo apt-get install python-dev gettext \
  libjpeg-dev libpng-dev \
  libxml2-dev libxslt-dev

Install the Weblate application dependencies:

sudo apt-get install python-django \
  python-django-registration python-django-south \
  python-social-auth python-imaging \
  python-pyicu python-git python-lxml \
  python-cairo python-gtk2 python-libravatar

A couple of Weblate dependencies are outdated in the Ubuntu repositories, so we will install these dependencies from the Python Package Index:

sudo apt-get install python-pip
sudo pip install --upgrade pillow
sudo pip install --upgrade whoosh
sudo pip install --upgrade translate-toolkit

Finally, as we opted for MySQL and Memcached, install the corresponding Python bindings:

sudo apt-get install python-mysqldb python-memcache

Download the Weblate source code

The Weblate source code is located in a public Github repository, clone the Git repository into the /opt/weblate directory.

sudo git clone \

Weblate configuration

The Weblate configuration is kept in a Django settings file, see Production setup in the Weblate documentation and Available settings in the Django documentation.

Copy the file weblate/ to weblate/

sudo cp /opt/weblate/weblate/ \

Edit the Weblate settings file:

sudo nano /opt/weblate/weblate/

Disable Django’s debug mode:

DEBUG = False

Configure the mail smtp server settings, see EMAIL_BACKEND:

EMAIL_HOST = 'your-smtp-host'
EMAIL_PORT = 'your-smtp-port'
EMAIL_HOST_USER = 'your-smtp-user'
EMAIL_HOST_PASSWORD = 'your-smtp-password'
EMAIL_USE_TLS = True or False

Complete the list of people who get code error notifications, when a view raises an exception, Django will email these people with the full exception information, see ADMINS:

  ('Your Admin Name', 'your-admin-email@your-domain')

Configure the MySQL database settings, see DATABASES:

  'default': {
    'ENGINE': 'django.db.backends.mysql',
    'NAME': 'weblate',
    'USER': 'weblate',
    'HOST': '',
    'PORT': '3306',

Set the time zone for this installation, see TIMEZONE:


By default, Weblate is configured to send the log information to syslog, you might want to store the log information into a separate log file, if if this is the case you can add a log file handler, see logging.handlers:

if DEBUG or not os.path.exists('/dev/log'):
    DEFAULT_LOG = 'console'
    DEFAULT_LOG = 'logfile'
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
    'formatters': {
        'syslog': {
            'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
        'simple': {
            'format': '%(levelname)s %(message)s'
        'logfile': {
            'format': '%(asctime)s %(levelname)s %(message)s'
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'simple'
        'syslog': {
            'level': 'DEBUG',
            'class': 'logging.handlers.SysLogHandler',
            'formatter': 'syslog',
            'address': '/dev/log',
            'facility': SysLogHandler.LOG_LOCAL2,
        'logfile': {
            'filename': "/var/log/weblate/weblate.log",
            'maxBytes': 100000,
            'backupCount': 3,
            'formatter': 'logfile',
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins', 'logfile'],
            'level': 'ERROR',
            'propagate': True,
        'weblate': {
            'handlers': [DEFAULT_LOG],
            'level': 'DEBUG',

You need to provide a secret key for this particular Django installation, it is used to provide a seed in secret-key hashing algorithms, see SECRET_KEY:


You can generate a random key with the following command:

openssl rand -base64 36

Edit the full path of the directory where the Git repositories are stored, this directory needs to be writable, see GIT_ROOT:

GIT_ROOT = '/var/opt/weblate/repos/'

Offload the updating of the full-text index to a separate process. Later we will configure a CRON job to update the index, see OFFLOAD_INDEXING:


Provide the full path of the directory where to put the full-text indexes, this directory needs to be writable, see WHOOSH_INDEX:

WHOOSH_INDEX = '/var/opt/weblate/whoosh-index'

Edit the list of domain names that this Django site can serve, see ALLOWED_HOSTS:

ALLOWED_HOSTS = ['.your-domain']

As we installed Memcached configure the default cache backend, see CACHES.

  'default': {
    'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    'LOCATION': '',

You can enable one or more Machine Translation services by providing the appropriate API keys.

If you want to use the Microsoft Translator service, register at Microsoft Translator, and configure your ID and secret:


If you want to use the Google Translate API you will need a Google API key, see Translate API Getting Started:


You must enable the machine translation services that you have configured:

#    'trans.machine.apertium.ApertiumTranslation',
#    'trans.machine.glosbe.GlosbeTranslation',
#    '',
#    'trans.machine.mymemory.MyMemoryTranslation',
#    'trans.machine.opentran.OpenTranTranslation',
#    'trans.machine.tmserver.AmagamaTranslation',
#    'trans.machine.tmserver.TMServerTranslation',
#    'trans.machine.weblatetm.WeblateSimilarTranslation',
#    'trans.machine.weblatetm.WeblateTranslation',

Configure the email address that error messages come from:

SERVER_EMAIL = 'your-admin-email@your-domain'

Default email address to use for various automated correspondence from the site managers, used for registration emails:

DEFAULT_FROM_EMAIL = 'your-admin-email@your-domain'

Initialize the Weblate database

Initialize the Weblate database, see syncdb:

cd /opt/weblate
sudo python ./ syncdb

You will be prompted for the Django superuser password, provide one and take note.

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no):
Username (leave blank to use 'root'):
E-mail address: your-superuser-email@your-domain

Synchronize the database state with the current set of models and migrations:

cd /opt/weblate
sudo python ./ migrate

Generate the Weblate localization files

cd /opt/weblate
sudo ./scripts/generate-locales

Setup the Weblate Apache Site

Create a new Apache site file:

sudo nano /etc/apache2/sites-available/weblate

Paste the following and adjust for your site, see Apache Core and modwsgi Configuration Directives:

# VirtualHost for weblate
<VirtualHost *:80>
  ServerName your-server-host-name
  ServerAdmin your-admin-user@your-domain

  DocumentRoot /opt/weblate/weblate/media/

  Alias /robots.txt /opt/weblate/weblate/media/robots.txt
  Alias /favicon.ico /opt/weblate/weblate/media/favicon.ico
  Alias /media/ /opt/weblate/weblate/media/
  Alias /doc/ /opt/weblate/weblate/html/
  Alias /static/admin /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/

  SetEnv HOME /var/opt/weblate

  WSGIDaemonProcess weblate user=weblate group=weblate processes=1 threads=15 home=/var/opt/weblate display-name=weblate python-path=/opt/weblate
  WSGIProcessGroup weblate

  <Directory /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/>
      Order deny,allow
      Allow from all
  <Directory /opt/weblate/weblate/media/>
      Order deny,allow
      Allow from all
  <Directory /opt/weblate/weblate/html/>
      Order deny,allow
      Allow from all
  <Directory /opt/weblate/weblate/examples/>
      Order deny,allow
      Allow from all

  WSGIScriptAlias / /opt/weblate/weblate/
  WSGIPassAuthorization On
  <Directory /opt/weblate/weblate>
      Order deny,allow
      Allow from all

Disable the default Apache site:

sudo a2dissite default

Enable the Weblate site:

sudo a2ensite weblate

Restart Apache:

sudo service apache2 restart

Access Weblate

At this point you should be able to access the Weblate administrative interface with a browser:


You can check if Weblate is configured properly visiting the Performace report:


You can also configure the Weblate users and permissions:


Program a CRON job for full-text indexing

As we specified the Weblate option OFFLOAD_INDEXING = True we will need to configure a CRON job to update the full-text index.

Start the crontab editor:

sudo -u weblate crontab -e

Add the following to the end of the file (update the index every 5 minutes):

*/5 * * * * /opt/weblate/ update_index

Setup your Git repository SSH key

In order to access your Git repository you will need to provide the repository private SSH key.

From your local machine copy the Git repository private SSH key to the server machine:

scp -i your-machine-key-file.pem your-git-rsa-file ubuntu@your-machine-public-dns:/home/ubuntu/

Open a terminal on the remote machine:

ssh -i your-machine-key-file.pem ubuntu@your-machine-public-dns

Move the Git repository SSH key to the /var/opt/weblate/.ssh/ directory.

sudo mv your-git-rsa-file /var/opt/weblate/.ssh/

Set ownership.

sudo chown weblate:weblate /var/opt/weblate/.ssh/your-git-rsa-file

Configure the SSH host:

cd /var/opt/weblate/.ssh
sudo -u weblate nano config

For example, if your repository is hosted on Bitbucket, paste the following:

  User git
  PreferredAuthentications publickey
  IdentityFile /var/opt/weblate/.ssh/your-git-rsa-file

For a Github hosted repository, paste the following:

  User git
  PreferredAuthentications publickey
  IdentityFile /var/opt/weblate/.ssh/your-git-rsa-file

Set permissions:

sudo chmod 700 /var/opt/weblate/.ssh
sudo chmod 600 /var/opt/weblate/.ssh/config
sudo chmod 600 /var/opt/weblate/.ssh/your-git-rsa-file

Test the SSH connection and add to the list of known hosts.

If your repository is hosted on Bitbucket:

sudo -u weblate ssh -T

If your repository is hosted on GitHub:

sudo -u weblate ssh -T

You will be prompted for confirmation:

Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'your-git-host' (RSA) to the list of known hosts.
logged in as your-user-name

Configure the Weblate translation projects

At this point you should be able to configure a Weblate translation project and subproject, see Adding translation and Translation organization on the Weblate documentation.

July 3, 2012

Installing Haskell ThreadScope on Ubuntu 12.04 precise

ThreadScope is a tool for performance profiling of parallel Haskell programs.

When I tried to install ThreadScope on Ubuntu 12.04 I ran into some problems. The following are the steps that allowed me to complete the installation.

Note that the haskell-platform package is already installed on the system.

First install the required GTK libraries.

sudo apt-get install libgtk2.0-dev libpango1.0-dev
sudo apt-get install libglib2.0-dev libcairo2-dev

Next install the gtk2hs-buildtools Haskell package.

sudo cabal update
sudo cabal install gtk2hs-buildtools

The following steps require running the gtk2hs tools. Although the ~/.cabal/bin directory is specified in my PATH variable, the setup process fails with the following message:

Cannot find gtk2hsC2hs Please install `gtk2hs-buildtools` first and check that the install directory is in your PATH (e.g. HOME/.cabal/bin).

You can fix this error by creating links to the gtk2hs tools in the /usr/bin directory.

sudo ln ~/.cabal/bin/gtk2hsC2hs /usr/bin/gtk2hsC2hs
sudo ln ~/.cabal/bin/gtk2hsHookGenerator /usr/bin/gtk2hsHookGenerator
sudo ln ~/.cabal/bin/gtk2hsTypeGen /usr/bin/gtk2hsTypeGen

Once the links are created you can install the other required packages.

sudo cabal install gtk
sudo cabal install cairo

Finally you can install the threadscope package.

sudo cabal install threadscope

June 30, 2012

Installing the Boost Libraries 1.50 on Ubuntu 12.04 precise

The version 1.50 of the Boost Libraries has been released . Following are the instructions to install a private copy of the Boost Libraries, including ICU support, on Ubuntu 12.04 (precise).


I have chosen to download the source packages in ~/Software, and to install in ~/usr but you can also use any other directories.

Make the required directories.

mkdir ~/Software
mkdir ~/Software/Boost
mkdir ~/Software/ICU
mkdir ~/usr


Check the required packages.

sudo apt-get install build-essential
sudo apt-get install g++
sudo apt-get install python-dev
sudo apt-get install libzip-dev
sudo apt-get install libbz2-dev

Download and install the ICU Libraries

We will install a private version of the ICU Libraries, I have chosen the ~/usr directory for the installation but can be any other.

Download and decompress the ICU Libraries source package.

cd ~/Software/ICU

tar -xvf icu4c-49_1_2-src.tgz

Configure, build and install the ICU Libraries.

cd icu/source
./runConfigureICU Linux --prefix=${HOME}/usr --enable-static
make install

Download the Boost Libraries

Download and decompress the Boost Libraries source package.

cd ~/Software/Boost
wget -O boost_1_50_0.tar.bz2

tar -xvf boost_1_50_0.tar.bz2

Configure the Boost Libraries

Declare the ICU_PATH environment variable.

export ICU_PATH=${HOME}/usr

Configure the Boost Libraries build system.

cd boost_1_50_0

Edit the generated project-config.jam file.

gedit project-config.jam

Make the required changes to the project-config.jam file. I have highlighted the required changes, note that you have to substitute the directory /home/your-user-name with your real home directory path.

# Boost.Build Configuration
# Automatically generated by

import option ;
import feature ;

# Compiler configuration. This definition will be used unless
# you already have defined some toolsets in your user-config.jam
# file.
if ! gcc in [ feature.values <toolset> ]
using gcc ;

project : default-build <toolset> gcc ;

# Python configuration
using python : 2.7 : /usr ;

path-constant ICU_PATH : /home/your-user-name/usr ;

# List of --with-<library> and --without-<library>
# options. If left empty, all libraries will be built.
# Options specified on the command line completely
# override this variable.
libraries = /home/your-user-name/usr ;

# These settings are equivivalent to corresponding command-line
# options.
option.set prefix : /home/your-user-name/usr ;
option.set exec-prefix : /home/your-user-name/usr ;
option.set libdir : /home/your-user-name/usr/lib ;
option.set includedir : /home/your-user-name/usr/include ;

# Stop on first error
option.set keep-going : false ;

Save the file and exit the editor.

Build and install Boost Libraries

Build the Boost Libraries.


Alternatively you can build the Boost Libraries enabling the C++11 compiler support.

./b2 toolset=gcc cxxflags=-std=c++0x

The build process takes a while, once it is complete you can install the private version of the Boost Libraries.

./b2 install

Installing Subversion 1.7 on Ubuntu 12.04 precise

Subversion 1.7 comes with many new features and improvements over earlier versions. A key feature introduced in Subversion 1.7 is the centralization of the working copy metadata storage into a single location. Instead of a .svn directory in every directory in the working copy, Subversion 1.7 working copies have just one .svn directory in the root.

If you are working with Ubuntu 12.04, the default Subversion package contains Subversion 1.6. Fortunately Dominik Stadler has published a Subversion 1.7 package for Ubuntu 12.04 (precise).

Following are the instructions to install Subversion 1.7 on Ubuntu 12.04 (precise).


First install some required dependencies:

sudo apt-get install python-software-properties

Install Subversion 1.7

Install Subversion 1.7 from Dominik Stadler PPA.

sudo apt-add-repository ppa:dominik-stadler/subversion-1.7
sudo apt-get update
sudo apt-get install subversion

Fix the SSL handshake error

The libneon27 library, that Subversion 1.7 uses, needs to be updated, otherwise you will receive the following error when accessing a server via https:

SSL handshake failed: SSL error: Key usage violation in certificate has been detected

Following are the instructions to install the updated libneon27 library on Ubuntu 12.04 (precise).

Remove the libneon27 library from your system (if it is installed):

sudo apt-get remove libneon27

Install libssl 0.9.8:

sudo apt-get install libssl0.9.8

Download and install an updated version of the libneon27 library (0.29.3-3).

If you are running Ubuntu 64 bits:

cd ~/Downloads
sudo dpkg -i libneon27_0.29.3-3_amd64.deb

If you are running Ubuntu 32 bits:

cd ~/Downloads
sudo dpkg -i libneon27_0.29.3-3_i386.deb

Now we will create a bash alias to preload the right libneon version when invoking the svn command. Edit your .bashrc file:

nano ~/.bashrc

Add the following alias at the end of the file:

alias svn='LD_PRELOAD=/usr/lib/ svn'

Save the .bashrc file and finally reload the .bashrc file:

source ~/.bashrc

Now you can test and use Subversion 1.7.

February 13, 2012

Building the text-icu Haskell package on MacOSX

Following are the instructions to compile the text-icu Haskell package on MacOSX (tested on MacOSX 10.7).

In order to compile the text-icu Haskell package we need to have the ICU libraries installed on the system.

We will use the MacPorts package manager to install the ICU libraries and header files.

If you don't have the MacPorts package manager installed on your system you should download and install it.

We update the port packages database and then we install the icu package. This step will install the required libraries and header files.

sudo port selfupdate

sudo port install icu

Finally, we update the cabal packages databases and we install the text-icu package specifying the locations of the include and lib directories.

sudo cabal update

sudo cabal install text-icu --extra-include-dirs=/opt/local/include --extra-lib-dirs=/opt/local/lib

July 2, 2011

Instalando Haskell Platform en Ubuntu 11.04

El paquete haskell-platform parece estar roto en Ubuntu 11.04 (Broken Haskell Platform in 11.04).

Podemos intentar reparar el paquete o realizar una instalación manual, esta última opción nos permite además instalar la versión más reciente de la plataforma.

Para instalar la versión 2011.2.0.1 de la Plataforma Haskell en Ubuntu 11.04 (Intel 32 bits) hemos seguido los pasos que se describen en el artículo Haskell Platform from Source on Unix-Like.

Hemos adoptado la siguiente configuración:

Directorio de construcción: ~/Software/Haskell/haskell-platform-2011.2.0.1

Directorio de instalación: /usr/local/haskell-patform-2011.2.0.1

El texto que aparece sobre fondo oscuro se debe introducir en una ventana de terminal.

Instalar las dependencias necesarias

sudo apt-get install libedit2 libedit-dev freeglut3-dev

sudo apt-get install libglu1-mesa-dev

sudo apt-get install libbsd-dev libgmp3-dev zlib1g-dev

Crear los directorios necesarios

mkdir ~/Software

mkdir ~/Software/Haskell

mkdir ~/Software/Haskell/haskell-platform-2011.2.0.1

sudo mkdir /usr/local/haskell-platform-2011.2.0.1

Descargar el compilador GHC

Vamos a descargar los archivos de la versión 7.0.3 del compilador GHC para Linux Intel 32 bits. Podemos consultar más información sobre otras plataformas en la página de distribución del compilador GHC.

cd ~/Software/Haskell/haskell-platform-2011.2.0.1


tar -xvf ghc-7.0.3-i386-unknown-linux.tar.bz2

Producir e instalar el compilador GHC

cd ~/Software/Haskell/haskell-platform-2011.2.0.1/ghc-7.0.3

./configure --prefix=/usr/local/haskell-platform-2011.2.0.1


sudo make install

Ajustar la variable de entorno PATH

Editar el archivo de perfil bash:

gedit ~/.bashrc

Agregar la línea siguiente, guardar y cerrar el editor:

export PATH=$PATH:/usr/local/haskell-platform-2011.2.0.1/bin

Después cerrar la ventana de terminal y abrir una nueva para cargar el perfil actualizado.

Comprobar acceso al compilador GHC

ghc --version

Descargar la Plataforma Haskell

cd ~/Software/Haskell/haskell-platform-2011.2.0.1


tar -xvf haskell-platform-2011.2.0.1.tar.gz

Producir e instalar la Plataforma Haskell

cd ~/Software/Haskell/haskell-platform-2011.2.0.1

cd haskell-platform-2011.2.0.1

./configure --prefix=/usr/local/haskell-platform-2011.2.0.1


sudo make install

Finalmente preparar el gestor de paquetes Cabal

cabal update