Turtl Server: an Evernote alternative

Ok, this is an evolution of the tutorial I posted on turtl google groups, with a step-by-step approach and some things corrected (I couldn’t be bothered to revisit the goggle groups post as you can’t edit it); The steps bellow are for installation of the turtl server on a debian minimal install with Apache:

			===== Install Turtl in Debian 8 =====


# In Debian 8 i386 with Lamp:

# Start by installing required packages:

apt-get install git wget curl libtool subversion gcc make automake

# 1. Install libuv:

cd /usr/local/src
wget http://dist.libuv.org/dist/v1.9.1/libuv-v1.9.1.tar.gz
tar -xf libuv-v1.9.1.tar.gz
rm libuv-v1.9.1.tar.gz
cd libuv-v1.9.1
sh autogen.sh
./configure
make
make install

# 2. Install RethinkDB

# Add the repo to your list and install via apt-get:

cd ~
echo “deb http://download.rethinkdb.com/apt lsb_release -cs main” | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
apt-get update
apt-get install rethinkdb

# Now configure the default instance:

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

# Restart rethinkdb:

systemctl restart rethinkdb

# 3. Install Common Lisp (ccl or sbcl)


# Move into the directory to host lisp:

cd /usr/local/src

# and download the package (http://ccl.clozure.com/download.html):

svn co http://svn.clozure.com/publicsvn/openmcl/release/1.11/linuxx86/ccl

# Copy the files to the system folder:

cp /usr/local/src/ccl/scripts/ccl /usr/local/bin

and/or

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

# Can test by starting lisp with the command:

ccl

or

ccl64

(quit)

cd ~

# 4. Install quickLisp


# Create new unpriviledged user for Turtl:

adduser turtl

Create a Data directory to store files:

mkdir -p /var/turtl/data
chown turtl:turtl /var/turtl/data
chmod 0755 /var/turtl/data

# Log in as turtl user:

su turtl
cd ~

# Download and install Quicklisp

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

ccl --load quicklisp.lisp

or

ccl64 --load quicklisp.lisp

# Within the Lisp sheel install quicklisp:

(quicklisp-quickstart:install)

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

(quit)

# Cleanup:

rm asdf.lisp quicklisp.lisp

# 5. Download and Install Turtl

git clone https://github.com/turtl/api.git
cd /home/turtl/api

# Create a file to host lisp commands:

vi launch.lisp

# and copy the bellow:

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

# Install a few missing dependencies in quicklisp:

cd /home/turtl/quicklisp/local-projects

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

# edit the ccl init conf file:

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

# and add the bellow at the end:

(cwd “/home/turtl/api”)
(load “/home/turtl/api/launch”)

# create the default turtl config file:

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

# edit as needed:

vi /home/turtl/api/config/config.lisp

# Configure to bind to local host:


(defvar *server-bind* "127.0.0.1"
  "The address to bind Turtl to (nil is the same as 0.0.0.0).")


# Also change the *site-url*, *admin-email*, and others - PLACE EVERYTHING BETWEEN " " )


# Change the Storage place to local

(defvar local-upload “/var/turtl/data”

# Start Lisp which should load turtl automatically:

ccl

or

ccl64

# turtl will build and creat db schema and launch - you should be able to access the server through a client by pointing it to http://turtl.yourdomain.com:8181

# ctrl + C to leave and (quit) to end lisp; 



# Go back to root/sudo user by exiting turtl

exit

# 6. Start Turtl at boot:


# Create an systemd service:

vi /lib/systemd/system/turtl.service

# Copy/Paste the bellow:

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

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

[Install]
WantedBy=multi-user.target

# Save and Close; 

# Give correct permissions:

chmod 0644 /lib/systemd/system/turtl.service

# Enable the service on boot:

systemctl enable turtl

# reboot





# 7. Configure Apache as reverse proxy serving https:


# Start by installing the required mods for apache:

apt-get install -y libapache2-mod-proxy-html libxml2-dev

# Enable with:

a2enmod

# Once you are prompted with the choice of modules, pass the below line listing the module names:

proxy proxy_ajp proxy_http rewrite deflate headers proxy_balancer proxy_connect proxy_html

# Configure the Virtual Host in Apache:

vi /etc/apache2/sites-available/turtl.conf

# Paste the bellow:

<VirtualHost *:80>

ServerName turtl.yourdomain.com
Redirect / https://turtl.yourdomain.com/
ServerAdmin webmaster@yourdomain.com

CustomLog ${APACHE_LOG_DIR}/turtl.log combined

<VirtualHost *:443>

ServerName turtl.yourdomain.com
ServerAdmin webmaster@yourdomain.com


SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA
SSLHonorCipherOrder     on
SSLCompression          off
SSLOptions +StrictRequire

If you’re using let’s encrypt

SSLCertificateFile /etc/letsencrypt/live/turtl.yourdomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/turtl.yourdomain.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/turtl.yourdomain.com/fullchain.pem

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
# Save and enable the site:

a2ensite turtl

# Restart apache

systemctl restart apache2

# Reboot and check that you can connect to turtl through any client (there is no webgui at this point) on your server's address:

https://turtl.yourdomain.com

2 Likes