Notice

This page show a previous version of the article

How to Install Tatoeba

Introduction

Unless you are a Windows user, we recommend that you use IMOUTO to install Tatoeba so that you do not have to configure everything manually.

If you are a Windows user or if for some reason you have issues with IMOUTO, you can still try to set things up manually. This article will try to guide you in doing that.

Required tools

You will need to install the following:

  • Apache
  • PHP 5.3
  • MySQL
  • Git client

Windows users

  • XAMPP will do the trick for Apache/PHP/MySQL. But you may need to use version 1.7.7 of XAMPP rather than the latest version, because Tatoeba currently uses PHP 5.3.
  • You can use Github for Windows as your Git client.

Mac or Linux users

Source code

Clone our Git repository. You can use the GitHub GUI or this command:

git clone https://github.com/Tatoeba/tatoeba2.git

On Windows, make sure that your local repository is stored under xampp\htdocs (for example, c:\xampp\htdocs). Otherwise, you will not have access to it.

Virtual host

If you already have some other websites set up on your machine, you will need to set up a virtual host. The point is that instead of going to something like http://localhost/tatoeba2, you go to some custom URL. I personally use http://tatoeba.dev/.

The reason is because CakePHP will not handle the URL rewriting properly if you try to browse through a subdirectory. You will get some error saying something like "The action tatoeba2 is not defined in controller PagesController".

If you don't know how to set up a virtual host, you should be able to find tutorial by googling it. Here are some links.

On Mac using XAMPP:

On Windows using XAMPP:

Briefly, you will need to edit your httpd-vhosts.conf and hosts files.

You will add a section like this to the end of the httpd-vhosts.conf file:

<VirtualHost *:80>
    DocumentRoot "C:\xampp\htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot "C:\xampp\htdocs\tatoeba2"
  ServerName tatoeba.dev
  <Directory "C:\xampp\htdocs\tatoeba2">
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

To edit your hosts file on Windows, make sure that:

  • your folder view options are not set up to hide system files (or you won't be able to see the hosts file)
  • you are editing as administrator (or you won't be able to save your changes)

Note that you will need to make sure that your hosts file contains the domain name that you want to use for your virtual host. For instance:

127.0.0.1    tatoeba.dev

Create the config files

core.php

Copy the file app/config/core.php.template and name it core.php.

Make sure you have the search and autotranscription disabled.

Configure::write('Search.enabled', false);
Configure::write('AutoTranscriptions.enabled', false);

database.php

Copy the file app/config/database.php.template and name it database.php.

In the file app/config/database.php, set your login, password and database in the $default array. If you want, you can set the value of 'password' to an empty string.

var $default = array(
    'driver' => 'mysql',
    'persistent' => false,
    'host' => 'localhost',
    'login' => 'root',
    'password' => 'somepassword',
    'database' => 'tatoeba',
    'prefix' => '',
    'encoding' => 'utf8'
);

You don't have to worry about the rest of the file at this stage.

Database

Create the database

First, create the database. Make sure the name you use here is the name you've set in app/core/database.php. I'll name it tatoeba.

Make sure you have started Apache and MySQL from the XAMPP Control Panel. Now you can issue "mysql -u root" to start MySQL from a prompt. Issue these commands:

CREATE DATABASE tatoeba;
USE tatoeba;

Create the tables and import the data

From Trang's database

The easiest solution is to download the copy of Trang's local database (60 MB). It contains data from 2010, that is around 600k sentences.

You can import the database with the command, which takes several minutes to run:

mysql -u username [-p] database_name < tatoeba_database.sql

Within this database, the passwords for all users have been set to 123.

You may need to execute some of the scripts in docs/database/updates if they have not been executed since the last time that Trang exported her database. Ask her.

From the scripts in docs/database

Another solution is to execute all the scripts in this order:

  • scripts in docs/database/tables
  • scripts in docs/database/triggers
  • scripts in docs/database/import

From there you will be able to log in with 123456 with one of the following usernames:

  • admin
  • corpus_maintainer
  • advanced_contributor
  • contributor
  • inactive
  • spammer

Other things you may have to configure

acl file

1) Create a script in your root folder. For instance, on Windows, you could call it acl.bat.

2) Copy-paste this code into the file:

CALL cake schema create DbAcl

for /f "tokens=*" %%a in (docs/database/acl/acos) do (
    CALL %%a
)

for /f "tokens=*" %%a in (docs/database/acl/aros) do (
    CALL %%a
)

for /f "tokens=*" %%a in (docs/database/acl/aros_acos) do (
    CALL %%a
)

PAUSE

3) Add these lines to the docs/database/acl/aros file:

cake acl create aro Group.1 User.5
cake acl create aro Group.2 User.6

These will give you two users, TRANG and MUIRIEL. TRANG (User.5) will have the permissions of an admin (Group.1), and MUIRIEL (User.6) will have the permissions of a corpus maintainer (Group.2) You can always add more lines later to give you additional users.

4) Make sure that cake/console/cake is on your path.

5) Run the batch file.

6) Say "yes" and "yes". It will prompt you to drop the tables and create new ones. The script executes the commands in the aco, aro and aros_acos file in docs/database/acl. These files define the permissions.

tmp folder writable

Make sure your /app/tmp/cache and all folders in it (models, persistent, views) are writable.

thread_stack for XAMPP on a Mac

You'll need to up the default thread_stack from 64K to 256K. /Applications/XAMPP/xamppfiles/etc/my.cnf thread_stack = 256K

short_open_tag = On

Make sure <? is allowed as an open tag. In your php.ini, check that you have:

short_open_tag = On

Other Things to Install

These can be ignored for local development of the code, but need to be installed in order to get the app fully operational.

  • imagick (for resizing images for profile avatars)
  • Sphinx search engine
  • Furigana
  • autocompletion for tags is based on suggestd (TODO put link an explanation on how to compile/use it)
  • for Chinese/Cantonese the transliteration is generated by sinoparserd (TODO add more explanation)
  • language autodetection is based on tatodetect