RACHEL on Linux (Ubuntu)

We currently package RACHEL for Windows and Raspberry Pi’s. We also provide an Android app with some instructions on how to get RACHEL working on Android. This chapter is intended to help you get RACHEL working on Linux computers that use Debian packages, and more specifically on Ubuntu. The material is being developed using Ubuntu Desktop 10.04 LTS, you may need to tweak these instructions for other versions of Ubuntu and for other flavours of Debian-based Linux environments.

Installing the web server

Caveat: I had already installed nginx earlier, so skipped some of the steps in the following article. Please read the following guide How To Install Linux, nginx, MySQL, PHP (LEMP) stack on Ubuntu 14.04 and follow the instructions. I made few changes for RACHEL, these include:

  • changing the filename from default to rachel
  • leaving the servername set to localhost
  • leaving cgi.fix_pathinfo commented out (at least until I complete these instructions)

Example configuration files

Here are some examples from my current Ubuntu laptop.

/etc/nginx/sites-available/rachel

 1 server {
 2         listen 80 default_server;
 3         listen [::]:80 default_server ipv6only=on;
 4 
 5         root  /home/julian/Downloads/rachel/rachelusb_32EN_3.1.5/rachelusb_32EN_\
 6 3.1.4/RACHEL/bin/www;
 7 
 8         index index.php index.html index.htm;
 9 
10         # Make site accessible from http://localhost/
11         server_name localhost;
12 
13         location / {
14                 # First attempt to serve request as file, then
15                 # as directory, then fall back to displaying a 404.
16                 try_files $uri $uri/ =404;
17         }
18 
19         error_page 404 /404.html;
20 
21         # redirect server error pages to the static page /50x.html
22         error_page 500 502 503 504 /50x.html;
23         location = /50x.html {
24                 root /usr/share/nginx/html;
25         }
26 
27         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
28         #
29         location ~ \.php$ {
30                 fastcgi_split_path_info ^(.+\.php)(/.+)$;
31                 try_files $uri =404;
32                 fastcgi_pass unix:/var/run/php5-fpm.sock;
33                 fastcgi_index index.php;
34                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
35                 include fastcgi_params;
36         }
37 }

After some fiddling (I’ll find out when I repeat these instructions on a clean machine) I managed to launch and run RACHEL in a web browser locally on the same machine. We would need to amend the security settings in nginx to allow remote access, TBC determine these changes. Limitations:

  • The full-text search from the RACHEL homepage doesn’t work at this stage, otherwise the web contents are useable, including the videos. We will get the full text search working in the next section.

Full-text search in RACHEL enables users to search and find contents that match their search term(s). RACHEL currently uses rsphider which in turn relies on mySQL. At the time of writing, RACHEL for Windows uses mySQL 5.6 while Ubuntu 14.04 LTS provides 5.5 by default. I discovered I needed to explicitly install 5.6 to get mySQL to accept the RACHEL mySQL databases.

Installing mySQL 5.6

sudo apt-get install mysql-server-5.6

We recommend running the script to enhance security:

Here was the error I got when I used 5.5 when starting mysqld : status: Env must be KEY=VALUE pairs ###Migrating RACHEL rsphider mySQL database files NB: This process doesn’t follow the recommended mySQL practices, we should be able to find more robust and standardised methods in future. For now, this seems to work and we probably should find ways to script the creating, maintenance and updating of the full-text database as a more strategic and elegant approach.

Overview of steps:

  • Hide the default databases: in /var/lib run sudo mv mysql mysql.local
  • Make a fresh empty location for our database files: sudo mkdir /var/lib/mysql
  • Copy RACHEL’s mySQL database files across: sudo cp -r /home/julian/Downloads/rachel/rachelusb_32EN_3.1.5/rachelusb_32EN_3.1.4/RACHEL/bin/bin/database/mysql-5.6.20/data/* /var/lib/mysql/
  • Run various sudo chown commands so the paths in `/var/lib/mysql/’ See below for examples.
  • Start mySQL.
  • Try the search in your web browser.
1 sudo chown -R mysql:mysql ib_logfile0
2 sudo chown -R mysql:mysql ib_logfile1
3 sudo chown -R mysql:mysql ibdata1 
4 sudo chown -R mysql:mysql sphider_plus 
5 sudo chown -R mysql:mysql performance_schema
6 sudo chown -R mysql:mysql .
7 sudo chown -R mysql:root mysql

The following reflects the current permissions (some were applied automatically after upgrading from mySQL 5.5 to 5.6)

 1 sudo ls -la /var/lib/mysql
 2 drwx------  6 mysql mysql     4096 May 24 20:51 .
 3 drwxr-xr-x 78 root  root      4096 May 24 20:50 ..
 4 -rw-r--r--  1 mysql mysql       56 May 24 20:42 auto.cnf
 5 -rw-r--r--  1 root  root         0 May 24 20:50 debian-5.6.flag
 6 -rw-r--r--  1 mysql mysql 12582912 May 24 20:50 ibdata1
 7 -rw-r--r--  1 mysql mysql 50331648 May 24 20:51 ib_logfile0
 8 -rw-r--r--  1 mysql mysql 50331648 May 24 20:42 ib_logfile1
 9 drwx------  2 mysql mysql     4096 May 24 20:51 mysql
10 -rw-rw----  1 root  root         6 May 24 20:51 mysql_upgrade_info
11 -rw-r--r--  1 mysql mysql     6425 May 24 20:42 nuc.err
12 -rw-r--r--  1 mysql mysql        5 May 24 20:42 nuc.pid
13 drwx------  2 mysql mysql     4096 May 24 20:51 performance_schema
14 drwxr-xr-x  2 mysql mysql     4096 May 24 20:42 sphider_plus
15 drwxr-xr-x  2 mysql mysql     4096 May 24 20:42 test

Sample Commands

http://localhost/rsphider/search.php?query_t=ethiopia&submit=Search&search=1&db=0&prefix=0

sudo service mysql start or use mysqld -v which provides more detailed information, especially useful if mySQL fails to start. dmesg | grep mysql is also useful to find reported problems when mySQL fails to start. sudo service mysql status mysql --user root -p then enter your password interactively, so it’s not stored in the command history mysql> show databases;

Extra notes

The following web site provides some useful ideas, including the test.php page. However the security settings differ from those used above and I prefer not to use them as they seem too permissive (too open). http://wiki.nginx.org/PHPFcgiExample

Known Unknowns

There are various things I know I don’t know. They’re not necessarily limited to running RACHEL on Linux, however I realised them during the process and they might as well be mentioned here.

  • How to install and configure RACHEL cleanly on Ubuntu (the above is distilled from the things I did which included some backtracking)
  • How the full-text index is created and updated
  • What the limitations are of the full-text search
  • What the appropriate security settings should be
  • How to configure nginx for access from other machines (where it can cope with the IP address changing and not having or using DNS)
  • What to do with the zipped sphider_plus.zip file used on Android