How to Install Turtl Server - Evernote Alternative - on Ubuntu 16.04

Turtl is a secure and encrypted Evernote alternative. It's an open source application that allows you to take notes, bookmark websites, store documents, share passwords with your coworkers. Turtl allows you to take control of all your data in the private place. The source code of turtl client and turtl server application is available on the github, and you can deploy it manually on your server.

In this tutorial, we will show you step-by-step how to install and configure the Turtl server on Ubuntu 16.04. The Turtl server is written in Common Lisp, so we need to install Common Lisp and QuickLisp on the system. This tutorial will also cover things like installing Libuv on an Ubuntu system and installing RethinkDB for the Turtl data store.

Prerequisites

  • Ubuntu 16.04
  • Root privileges

What we will do

  1. Install Dependencies
  2. Install Libuv on Ubuntu 16.04
  3. Install and Configure RethinkDB
  4. Install Common Lisp
  5. Install Quicklisp
  6. Download and Install Turtl Server
  7. Run Turtl Server as a Service
  8. Install and configure Apache as a Reverse Proxy for Turtl
  9. Testing

Step 1 - Install Dependencies

Update your Ubuntu server repository, then update the system.

sudo apt update
sudo apt upgrade

Now install some required packages - including git, wget, and automake - using the apt command below.

sudo apt install wget curl libtool subversion make automake git -y

Step 2 - Install Libuv on Ubuntu 16.04

Libuv is multi-platform support library focused on asynchronous I/O. This library is needed by the Turtl server, and we will install it manually.

Go to the '/usr/local/src' directory and download the Libuv compressed file using wget.

cd /usr/local/src
wget http://dist.libuv.org/dist/v1.9.1/libuv-v1.9.1.tar.gz

Extract the libuv.tar.gz file and remove it.

tar -xf libuv-v1.9.1.tar.gz
rm libuv-v1.9.1.tar.gz

Go to the libuv directory.

cd libuv-v1.9.1

Now build the Libuv library with autotools - run all commands below.

sh autogen.sh
./configure
make
make install

And when it's complete, you will get the result as shown below.

Build Libuv

The Libuv library has been added to the system in the '/usr/local/lib' directory.

Step 3 - Install RethinkDB

RethinkDB is an open source and distributed document-oriented database, and the Turtl server data store uses RethinkDB.

In this step, we will install RethinkDB from its own, official repository.

Add RethinkDB repository to the system.

echo "deb http://download.rethinkdb.com/apt $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list

Download and add the key.

wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -

Update the Ubuntu repository and install it using apt commands below.

sudo apt update
sudo apt install rethinkdb -y

Install RethinkDB

After the installation is complete, copy the default configuration to the '/etc/rethinkdb/instances.d' directory.

cp /etc/rethinkdb/default.conf.sample /etc/rethinkdb/instances.d/default.conf

And restart the rethinkdb service.

systemctl restart rethinkdb
systemctl enable rethinkdb

RethinkDB has been installed on the Ubuntu system - check it using the command below.

netstat -plntu

Check if RethinkDB is active

Step 4 - Install Common Lisp (CL)

Common Lisp (CL) is a dialect of the Lisp programming language - it's a member of the Lisp family.

In this step, we will install manually 'Clozure Common Lisp' on the Ubuntu system.

Go to the '/usr/local/src' directory and download 'Clozure Common Lisp' for Linux 86/64-bit using wget command.

cd /usr/local/src
wget https://github.com/Clozure/ccl/releases/download/v1.11.5/ccl-1.11.5-linuxx86.tar.gz

Extract the 'Common Lisp' compressed file and remove it.

tar -xf ccl-1.11.5-linuxx86.tar.gz
rm -f ccl-1.11.5-linuxx86.tar.gz

And you will get the 'ccl' directory. Goto the 'ccl' directory and copy the 'ccl64' bin file to the '/usr/local/bin' directory.

cd /usr/local/src/ccl
sudo cp scripts/ccl64 /usr/local/bin/

Now verify the 'Common Lisp' installation by running the 'ccl64' command.

ccl64

And make sure you get the result as below.

Install Common Lisp

'Clozure Common lisp' has now has been installed. And if you want to exit from the 'ccl' shell, type the quit command as below.

(quit)

Step 5 - Install Quicklisp

Quicklisp is a library manager for Common Lisp. We need 'Quicklisp' installed on the system because Turtl loads all of its dependencies through the Quicklisp system.

Before installing Quicklisp, please add a new user for turtl installation.

useradd -m -s /bin/bash turtl
passwd turtl

Now login as the 'turtl' user.

su - turtl

Download the 'quicklisp.lisp' and 'asdf.lisp' files using wget/curl commands in the following way.

wget https://common-lisp.net/project/asdf/asdf.lisp
curl -O https://beta.quicklisp.org/quicklisp.lisp

Install Quicklisp

Now load 'quicklisp.lisp' using the 'ccl64' command as shown below.

ccl64 --load quicklisp.lisp

And you will get the 'ccl' shell command line. Install Quicklisp using the command below.

(quicklisp-quickstart:install)

Install Quicklisp

The command will download all dependencies for Quicklisp. And after it's complete, add the Quicklisp 'init' file and load 'asdf.lisp'.

(ql:add-to-init-file)
(load (compile-file "asdf.lisp"))

When it's complete, exit from the 'ccl' shell.

(quit)

And remove 'quicklisp.lisp' and 'asdf.lisp' files.

rm -f asdf.lisp quicklisp.lisp

Quicklisp has been installed to the system under 'turtl' user.

Quicklisp has been installed to the system under 'turtl' user

Step 6 - Download and Install turtl

In this step, we will install Turtl through the 'turtl' user we've already created.

Login as the 'turtl' user and clone the turtl source code using git.

su - turtl
git clone https://github.com/turtl/api.git

Go to the 'api' directory and create a new file called 'launch.lisp' using vim.

cd /home/turtl/api
vim launch.lisp

Paste the following configuration there.

(pushnew "./" asdf:*central-registry* :test #'equal)
(load "start")

Save and exit.

Next, we need to install some dependencies for turtl. Go to the quicklisp directory and clone all dependencies.

cd ~/quicklisp/local-projects

Download all dependencies by running commands below.

git clone git://github.com/orthecreedence/cl-hash-util
git clone git://github.com/orthecreedence/vom
git clone git://github.com/orthecreedence/cl-async
git clone git://github.com/orthecreedence/cffi
git clone git://github.com/orthecreedence/wookie
git clone git://github.com/orthecreedence/cl-rethinkdb
git clone git://github.com/orthecreedence/cl-libuv
git clone git://github.com/orthecreedence/drakma-async
git clone https://github.com/Inaimathi/cl-cwd.git

And edit the ccl init file.

vim /home/turtl/.ccl-init.lisp

Goto the end, and paste the following configuration there.

(cwd "/home/turtl/api")
(load "/home/turtl/api/launch")

Save and exit.

Now copy the default turtl configuration 'config.lisp and edit it using vim.

cp /home/turtl/api/config/config.default.lisp /home/turtl/api/config/config.lisp
vim /home/turtl/api/config/config.lisp

On the 'server-bind' line, add the localhost IP address as shown below.

defvar *server-bind* "127.0.0.1"

Save and exit.

After all of the configuration is complete, start the turtl server using the 'ccl64' command.

ccl64

The command will install Turtl server API, and when it's complete you will get the result as shown below.

Install turtl

Press 'Ctrl + c' to exit.

The Turtl server is now running under local IP address "127.0.0.1" with port "8181".

Open new terminal of your server, then check it using netstat command below.

netstat -plntu

And you should get the result as below.

Check turtl install

Step 7 - Running Turtl as a Service

The Turtl server API has been installed through the 'turtl' user. And for this tutorial, we will run turtl as a service.

Go to the '/lib/systemd/system' directory and create a new 'turtl.service' file using vim.

cd /lib/systemd/system/
vim turtl.service

Paste the following turtl service configuration there.

[Unit]
Description=turtl_service
After=network.target mysql.service postgresql.service

[Service]
User=turtl
ExecStart=/usr/local/bin/ccl64
Restart=always

[Install]
WantedBy=multi-user.target

Save and exit.

Now reload systemd and start the turtl service using the systemctl command.

systemctl daemon-reload
systemctl start turtl

Running Turtl as a Service

Enable the turtl service to launch everytime at system boot, and check the turtl service status.

systemctl enable turtl
systemctl status turtl

You should get the result as below.

Enable turtl service

The turtl service is now running as a service on Ubuntu system.

Step 8 - Configure Apache Reverse proxy for Turtl

In this tutorial, we will run Turtl server under the Apache/httpd reverse proxy server. The Turtl server is running under at local IP '127.0.0.1' with port '8181', and now we will install the Apache2 web server and configure it as a reverse proxy for Turtl server.

Install apache2 with all dependencies using the apt command below.

sudo apt install -y apache2 apache2-utils apache2-bin libxml2-dev

After the installation is complete, enable some plugins needed by running the following commands.

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_ajp
sudo a2enmod rewrite
sudo a2enmod deflate
sudo a2enmod headers
sudo a2enmod proxy_balancer
sudo a2enmod proxy_connect
sudo a2enmod proxy_html
sudo a2enmod xml2enc

Now restart the Apache2 web server and enable it to launch everytime at boot time.

systemctl restart apache2
systemctl enable apache2

Next, add a new turtl virtual host by creating new configuration file 'turtl.conf' under the 'sites-available' directory.

Goto the '/etc/apache2/sites-available' directory and create new cconfiguration 'turtl.conf' using vim.

cd /etc/apache2/sites-available/
vim turtl.conf

Paste the virtual host configuration below.

<VirtualHost *:80>

ServerName turtl.hakase-labs.co
ServerAdmin [email protected]

ProxyPreserveHost On
ProxyRequests off
ProxyPass / http://127.0.0.1:8181/ Keepalive=On timeout=1600
ProxyPassReverse / http://127.0.0.1:8181/

LogLevel info

CustomLog ${APACHE_LOG_DIR}/turtl.log combined

</VirtualHost>

Save and exit.

Now activate the turtl virtual host and check the configuration.

a2ensite turtl
apachectl configtest

Make sure you get no error, then restart the apache2 web server.

systemctl restart apache2

Check the service using the netstat command.

netstat -plntu

And make sure you get the Apache web server on port 80 and the Turtl API server on the '127.0.0.1' with port '8181'.

Step 9 - Testing

Download the turtl client application and open it.

Click on 'Create an Account'.

Create account in turtl

Now click the 'I will remember my login' button.

Remember login

Type your email address with password and your Turtl server domain name.

Set a password

And click the 'Join' button.

Now you will get the new window - click the 'skip this step' button.

Click join button

And you will get the blank turtl dashboard. You can add new note, password, files, bookmark etc.

Turtl dashboard

The Turtl server installation on Ubuntu 16.04 has been completed successfully.

Reference

Share this page:

10 Comment(s)