Version at: 23/03/2014, 20:31 vs. version at: 26/03/2014, 21:46
11#How to Prepare a Development Environment for Tatoeba Using a Pre-made Virtual Machine
22
33## Installing the VM
44* Grab the vm file [http://mirrors.bouah.net/pub/tatoeba/Tatovm/](http://mirrors.bouah.net/pub/tatoeba/Tatovm/)
55
66* Untar the file:
77
88 * On Windows:
99
1010 * Download both the vbox and the gz file
1111
12 * Use 7zip [http://www.7-zip.org/] to extract Tatovm.vmdk file from the gz file (using the "Extract here" item from the right-click menu)
12 * Use [7zip](http://www.7-zip.org/) to extract Tatovm.vmdk file from the gz file (using the "Extract here" item from the right-click menu)
1313
1414 * On Linux: use file-roller or from the terminal, type:
15 xz -d Tatovm.vmdk.xz
1516
16 tar -xvf vmfile
17### Using VirtualBox
1718
18* Get and install VirtualBox [https://www.virtualbox.org/wiki/Downloads]
19* Get and install [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
1920
2021* Load the VM files in VirtualBox:
2122
2223 From the GUI: **Machine -> Add**, then browse to the location of the .vbox file
2324
2425 From the command line: VBoxManage registervm /path/to/vm.vbox
26
27### Using Qemu
28
29* Get and install [qemu](http://en.wikibooks.org/wiki/QEMU/Installing_QEMU)
30
31* Run the following command: (tweak the -m flag for more ram)
32
33 qemu-system-i386 Downloads/Tatovm.vmdk -smp 4 -m 512 -enable-kvm -net nic -net user -redir tcp:8080::80 -redir tcp:4242::22 -redir tcp:8081::81
2534
2635## Accessing the VM
2736* The default http port is 8080 and the default SSH port is 4242.
2837
2938* On Windows, you may want to download [PuTTY](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) as your SSH GUI.
3039
3140* To SSH into the machine, use the username **tatoeba** and password **tatoeba**:
3241
3342 ssh -p 4242 tatoeba@127.0.0.1
3443
3544* Now you can see the website running in your browser by pointing it to the following address:
3645
3746 127.0.0.1:8080
3847
39* Steps such as installing packages require superuser privileges. Prior to such steps, execute:
48* Steps such as installing packages require superuser privileges. Prefix these commands with sudo or run:
4049
41 su -
50 sudo su
4251
43 Type in the password **tatovm** when prompted.
52 Then type in the password **tatoeba** when prompted.
4453
4554 After performing your operation, execute "exit" to end superuser access.
4655
47* The MySQL user is **root** and password is **tatoeba** in case you need to do operations directly on the table or import more data.
56* The MySQL user is **root** and password is **tatoeba** in case you need to do operations directly on the table or import more data. Getting to a mysql shell or excuting a mysql script is as easy as:
4857
58 mysql -u root -ptatoeba tatoeba
59
60 mysql -u root -ptatoeba tatoeba < script.sql
4961
5062##Performing Additional Configuration Steps
51
52These steps will eventually be folded into a new VM, but for now, they must be performed after the VM is installed.
53
54* Optional: add the following to .bashrc:
55
56 export TERM=xterm-256color
57
58* Log in as superuser (see above) and execute these commands:
59
60 apt-get update
61
62 apt-get install git
63
64 apt-get install php5-curl
65
66 apt-get install bzr *(used with UI translations)*
67
68 apt-get install libpq5 *(used with Sphinx)*
69
70 apt-get install poedit *(used with UI translations)*
71
72 apt-get install flac *(used with audio)*
73
74 apt-get install lame *(used with audio)*
75
76 apt-get install imagemagick *(used for images uploaded to profile)*
77
78 apt-get install php5-imagick *(used for images uploaded to profile)*
79
80* The current VM was assembled shortly before we made the transition from a Subversion repository on Assembla to a Git repository on GitHub, so execute the following steps to update your code from the new repository:
81
82 * Log in as superuser.
83
84 * Rename /var/http/tatoeba to /var/http/tatoeba-bak .
85
86 * Execute this line:
87 chmod 0777 /var/http
88
89 * Log out as superuser (important).
90
91 * In the /var/http directory, pull the code from the [GitHub Tatoeba repository](https://github.com/Tatoeba/tatoeba2) as follows:
92
93 git clone https://github.com/Tatoeba/tatoeba2.git /var/http/tatoeba
9463
9564 * If you will be committing code, configure your user.name and user.email. (You can do this retroactively after your first commit, but it's better to do it beforehand.) For instance, if your username at GitHub is ghuser, and your e-mail address is address@example.com, you'll execute:
9665
9766 git config --global user.name "ghuser"
9867
9968 git config --global user.email address@example.com
10069
10170 * Your new directory /var/http/tatoeba should have the same directory structure as the old /var/http/tatoeba-bak. You can now delete /var/http/tatoeba-bak .
10271
103* Execute SQL scripts as follows:
104
105 mysql -u root -ptatoeba tatoeba < /var/http/tatoeba/docs/database/updates/2013-05-31.sql
106
107 mysql -u root -ptatoeba tatoeba < /var/http/tatoeba/docs/database/updates/2013-08-13.sql
108
109 mysql -u root -ptatoeba tatoeba < /var/http/tatoeba/docs/database/scripts/create\_fill\_langStats.sql
110
111* Log into mysql (with "mysql -u root -ptatoeba tatoeba"). Execute the following statement:
112
113 SELECT MAX(id) FROM sentences;
114
115 Based on the return value (for example, 2976558), execute a statement like the following:
116
117 DELETE FROM sentences\_translations WHERE translation\_id > 2976558 OR sentence\_id > 2976558;
118
119 The statement deletes dangling links that point to sentences whose IDs are higher than the maximum that is actually in the database. If you do not execute this statement, the new sentences that you add may match these dangling pointers and end up having incorrect links.
120
121* As superuser, make tmp/cache and its subfolders writable:
122
123 chmod 0777 /var/http/tatoeba/app/tmp/cache/
124
125 chmod 0777 /var/http/tatoeba/app/tmp/cache/*
126
127 chmod 0777 /var/http/tatoeba/app/webroot/img/profiles_36
128
129 chmod 0777 /var/http/tatoeba/app/webroot/img/profiles_128
130
131* As superuser, restart apache:
132
133 /etc/init.d/apache2 restart
134
13572* You may find it useful at this point to back up your databases so that you can return them to their virgin state. Make a directory (for instance, /backup ; this may require root permission) and then execute a command such as this one:
13673
13774 mysqldump -u root -ptatoeba -A > /backup/all_dbs.sql
138
139## Install and Configure Sphinx Search
140
141Follow the instructions under [Installing and Configuring Sphinx Search](install-sphinx).
14275
14376## Customizing Your Installation
14477* There are three ways to access the codebase via your favorite editor in the comfort of your host computer:
14578
14679 * Mount a drive over SSH:
14780
14881 * On Windows: download NetDrive [www.netdrive.net] and use the aforementioned credentials and port
14982
15083 * On Linux: install SSHFS and then mount it using:
15184
15285 sshfs tatoeba@127.0.0.1:4242 /path/to/mountpoint
15386
15487 * Mount a drive over WebDAV:
15588
156 * On Windows: use NetDrive. The user and password are **tatoeba**, and the port is 8080.
89 * On Windows: use NetDrive. The user and password are **tatoeba**, and the port is **8081**.
15790
15891 * On Linux: use your favorite file manager with WebDAV support, or install cadaver and connect using the above credentials.
15992
16093 * Mount a shared file (slow and not recommended):
16194
16295 * Set up Guest additions [https://help.ubuntu.com/community/VirtualBox/GuestAdditions]
16396
16497 * In the GUI select Devices -> Shared Folders -> Add
16598
16699 * Browse to the folder you want to share from your host and select it
167100
168101 * Select the Make permanent option
169102
170103 * Now mount the shared file on the guest system:
171104
172105 mount -t vboxfs /media/sharefoldername /path/to/mountpoint
173106
174107* You can also install a graphical environment (GNOME or any other development environment) to work directly from the VM:
175108
176109 apt-get install task-gnome-desktop
177110
178111##Logging Into Tatoeba on the VM
179112
180113The users provided by default are:
181114
182115 admin
183116
184117 corpus_maintainer
185118
186119 advanced_contributor
187120
188121 contributor
189122
190123 inactive
191124
192125 spammer
193126
194127The default password for each user is '123456'.
195128
196129In addition, you can register new users.
diff view generated by jsdifflib

Version at: 23/03/2014, 20:31

#How to Prepare a Development Environment for Tatoeba Using a Pre-made Virtual Machine

## Installing the VM
* Grab the vm file [http://mirrors.bouah.net/pub/tatoeba/Tatovm/](http://mirrors.bouah.net/pub/tatoeba/Tatovm/)

* Untar the file:

   * On Windows: 

        * Download both the vbox and the gz file

        * Use 7zip [http://www.7-zip.org/] to extract Tatovm.vmdk file from the gz file (using the "Extract here" item from the right-click menu)

   * On Linux: use file-roller or from the terminal, type:

   tar -xvf vmfile

* Get and install VirtualBox [https://www.virtualbox.org/wiki/Downloads]

* Load the VM files in VirtualBox:

  From the GUI: **Machine -> Add**, then browse to the location of the .vbox file

  From the command line: VBoxManage registervm /path/to/vm.vbox

## Accessing the VM
* The default http port is 8080 and the default SSH port is 4242.

* On Windows, you may want to download [PuTTY](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) as your SSH GUI.

* To SSH into the machine, use the username **tatoeba** and password **tatoeba**:

   ssh -p 4242 tatoeba@127.0.0.1

* Now you can see the website running in your browser by pointing it to the following address:

   127.0.0.1:8080

* Steps such as installing packages require superuser privileges. Prior to such steps, execute:

   su -   

   Type in the password **tatovm** when prompted.

   After performing your operation, execute "exit" to end superuser access.

* The MySQL user is **root** and password is **tatoeba** in case you need to do operations directly on the table or import more data.


##Performing Additional Configuration Steps

These steps will eventually be folded into a new VM, but for now, they must be performed after the VM is installed. 

* Optional: add the following to .bashrc:

    export TERM=xterm-256color

* Log in as superuser (see above) and execute these commands:

    apt-get update

    apt-get install git

    apt-get install php5-curl

    apt-get install bzr *(used with UI translations)*

    apt-get install libpq5  *(used with Sphinx)*

    apt-get install poedit *(used with UI translations)*

    apt-get install flac *(used with audio)*

    apt-get install lame *(used with audio)*

    apt-get install imagemagick *(used for images uploaded to profile)*

    apt-get install php5-imagick *(used for images uploaded to profile)*

* The current VM was assembled shortly before we made the transition from a Subversion repository on Assembla to a Git repository on GitHub, so execute the following steps to update your code from the new repository:

    * Log in as superuser.

    * Rename /var/http/tatoeba to /var/http/tatoeba-bak .

    * Execute this line: 
   chmod 0777 /var/http

    * Log out as superuser (important).
 
    * In the /var/http directory, pull the code from the [GitHub Tatoeba repository](https://github.com/Tatoeba/tatoeba2) as follows:

    git clone https://github.com/Tatoeba/tatoeba2.git /var/http/tatoeba

    * If you will be committing code, configure your user.name and user.email. (You can do this retroactively after your first commit, but it's better to do it beforehand.) For instance, if your username at GitHub is ghuser, and your e-mail address is address@example.com, you'll execute:

        git config --global user.name "ghuser"

        git config --global user.email address@example.com

    * Your new directory /var/http/tatoeba should have the same directory structure as the old /var/http/tatoeba-bak. You can now delete /var/http/tatoeba-bak .

* Execute SQL scripts as follows:

    mysql -u root -ptatoeba tatoeba < /var/http/tatoeba/docs/database/updates/2013-05-31.sql

    mysql -u root -ptatoeba tatoeba < /var/http/tatoeba/docs/database/updates/2013-08-13.sql

    mysql -u root -ptatoeba tatoeba < /var/http/tatoeba/docs/database/scripts/create\_fill\_langStats.sql

* Log into mysql (with "mysql -u root -ptatoeba tatoeba"). Execute the following statement:

    SELECT MAX(id) FROM sentences;

    Based on the return value (for example, 2976558), execute a statement like the following:

    DELETE FROM sentences\_translations WHERE translation\_id > 2976558 OR sentence\_id > 2976558;

    The statement deletes dangling links that point to sentences whose IDs are higher than the maximum that is actually in the database. If you do not execute this statement, the new sentences that you add may match these dangling pointers and end up having incorrect links.

* As superuser, make tmp/cache and its subfolders writable:

   chmod 0777 /var/http/tatoeba/app/tmp/cache/

   chmod 0777 /var/http/tatoeba/app/tmp/cache/*

   chmod 0777 /var/http/tatoeba/app/webroot/img/profiles_36 

   chmod 0777 /var/http/tatoeba/app/webroot/img/profiles_128

* As superuser, restart apache:

   /etc/init.d/apache2 restart
 
* You may find it useful at this point to back up your databases so that you can return them to their virgin state. Make a directory (for instance, /backup ; this may require root permission) and then execute a command such as this one:

    mysqldump -u root -ptatoeba -A > /backup/all_dbs.sql

## Install and Configure Sphinx Search

Follow the instructions under [Installing and Configuring Sphinx Search](install-sphinx).
 
## Customizing Your Installation
* There are three ways to access the codebase via your favorite editor in the comfort of your host computer:

   * Mount a drive over SSH:

       * On Windows: download NetDrive [www.netdrive.net] and use the aforementioned credentials and port

       * On Linux: install SSHFS and then mount it using:

       sshfs tatoeba@127.0.0.1:4242 /path/to/mountpoint

    * Mount a drive over WebDAV:

        * On Windows: use NetDrive. The user and password are **tatoeba**, and the port is 8080.

        * On Linux: use your favorite file manager with WebDAV support, or install cadaver and connect using the above credentials.

    * Mount a shared file (slow and not recommended):

        * Set up Guest additions [https://help.ubuntu.com/community/VirtualBox/GuestAdditions]

        * In the GUI select Devices -> Shared Folders -> Add

        * Browse to the folder you want to share from your host and select it

        * Select the Make permanent option

        * Now mount the shared file on the guest system:

       mount -t vboxfs /media/sharefoldername /path/to/mountpoint

* You can also install a graphical environment (GNOME or any other development environment) to work directly from the VM:

  apt-get install task-gnome-desktop

##Logging Into Tatoeba on the VM

The users provided by default are:

    admin

    corpus_maintainer

    advanced_contributor

    contributor

    inactive

    spammer

The default password for each user is '123456'.

In addition, you can register new users.

version at: 26/03/2014, 21:46

#How to Prepare a Development Environment for Tatoeba Using a Pre-made Virtual Machine

## Installing the VM
* Grab the vm file [http://mirrors.bouah.net/pub/tatoeba/Tatovm/](http://mirrors.bouah.net/pub/tatoeba/Tatovm/)

* Untar the file:

   * On Windows: 

        * Download both the vbox and the gz file

        * Use [7zip](http://www.7-zip.org/) to extract Tatovm.vmdk file from the gz file (using the "Extract here" item from the right-click menu)

   * On Linux: use file-roller or from the terminal, type:
   xz -d Tatovm.vmdk.xz

### Using VirtualBox

* Get and install [VirtualBox](https://www.virtualbox.org/wiki/Downloads)

* Load the VM files in VirtualBox:

  From the GUI: **Machine -> Add**, then browse to the location of the .vbox file

  From the command line: VBoxManage registervm /path/to/vm.vbox

### Using Qemu

* Get and install [qemu](http://en.wikibooks.org/wiki/QEMU/Installing_QEMU)

* Run the following command: (tweak the -m flag for more ram)

  qemu-system-i386 Downloads/Tatovm.vmdk -smp 4 -m 512 -enable-kvm -net nic -net user -redir tcp:8080::80 -redir tcp:4242::22 -redir tcp:8081::81

## Accessing the VM
* The default http port is 8080 and the default SSH port is 4242.

* On Windows, you may want to download [PuTTY](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) as your SSH GUI.

* To SSH into the machine, use the username **tatoeba** and password **tatoeba**:

   ssh -p 4242 tatoeba@127.0.0.1

* Now you can see the website running in your browser by pointing it to the following address:

   127.0.0.1:8080

* Steps such as installing packages require superuser privileges. Prefix these commands with sudo or run:

   sudo su

   Then type in the password **tatoeba** when prompted.

   After performing your operation, execute "exit" to end superuser access.

* The MySQL user is **root** and password is **tatoeba** in case you need to do operations directly on the table or import more data. Getting to a mysql shell or excuting a mysql script is as easy as:

  mysql -u root -ptatoeba tatoeba

  mysql -u root -ptatoeba tatoeba < script.sql

##Performing Additional Configuration Steps

    * If you will be committing code, configure your user.name and user.email. (You can do this retroactively after your first commit, but it's better to do it beforehand.) For instance, if your username at GitHub is ghuser, and your e-mail address is address@example.com, you'll execute:

        git config --global user.name "ghuser"

        git config --global user.email address@example.com

    * Your new directory /var/http/tatoeba should have the same directory structure as the old /var/http/tatoeba-bak. You can now delete /var/http/tatoeba-bak .

* You may find it useful at this point to back up your databases so that you can return them to their virgin state. Make a directory (for instance, /backup ; this may require root permission) and then execute a command such as this one:

    mysqldump -u root -ptatoeba -A > /backup/all_dbs.sql
 
## Customizing Your Installation
* There are three ways to access the codebase via your favorite editor in the comfort of your host computer:

   * Mount a drive over SSH:

       * On Windows: download NetDrive [www.netdrive.net] and use the aforementioned credentials and port

       * On Linux: install SSHFS and then mount it using:

       sshfs tatoeba@127.0.0.1:4242 /path/to/mountpoint

    * Mount a drive over WebDAV:

        * On Windows: use NetDrive. The user and password are **tatoeba**, and the port is **8081**.

        * On Linux: use your favorite file manager with WebDAV support, or install cadaver and connect using the above credentials.

    * Mount a shared file (slow and not recommended):

        * Set up Guest additions [https://help.ubuntu.com/community/VirtualBox/GuestAdditions]

        * In the GUI select Devices -> Shared Folders -> Add

        * Browse to the folder you want to share from your host and select it

        * Select the Make permanent option

        * Now mount the shared file on the guest system:

       mount -t vboxfs /media/sharefoldername /path/to/mountpoint

* You can also install a graphical environment (GNOME or any other development environment) to work directly from the VM:

  apt-get install task-gnome-desktop

##Logging Into Tatoeba on the VM

The users provided by default are:

    admin

    corpus_maintainer

    advanced_contributor

    contributor

    inactive

    spammer

The default password for each user is '123456'.

In addition, you can register new users.

Note

The lines in green are the lines that have been added in the new version. The lines in red are those that have been removed.