Skip to content

Install Tracks 2.5 on Ubuntu 20.10

ghost-from-the-past edited this page Jun 14, 2021 · 3 revisions

This is based on the previous installation guides (from where I shamelessly copy and paste several parts)

Don't forget in case you need some help to consult/write in the users group :
https://groups.google.com/g/tracksapp


I wrote the solutions for the problems I found during my installation but don't worry you will find new ones...

For this guide I assume

- you have a fresh Ubuntu 20.10 installation.

- Tracks will be served by Phusion Passenger through Apache in a subdir of its own.

- MySQL will be used for the database.


it is not the best practice... but normally I do

>sudo -i

at the beginning to avoid all the sudos during the installation

Install LAMP

LAMP = Linux, Apache, MySQL, PHP

We'll just install Apache and MySQL

>apt install apache2
>apt install mysql-server
>apt install mysql-client

>systemctl enable apache2.service
>systemctl enable mysql
>systemctl start mysql.service

The last three lines set to automatically start Apache web server and MySQL database server when you boot and starts the MySQL (Apache is still off). For more information see Apache tips and MySQL tips

MySQL - change the default of default_authentication_plugin

Follow the instruction at MySQL tips#mysql---change-the-default-of-default_authentication_plugin to change the default authentication used by MySQL. Because Tracks uses mysql_native_password strategy which is not anymore the default one.

Install Ruby

Tracks requires Ruby 2.5 or greater. At the time of this guide the installed version was 2.7.1

Install the following packages

>apt install unzip
>apt install zlib1g-dev
>apt install ruby
>apt install rubygems
>apt install bundler
>apt install thin
>apt install build-essential
>apt install libapache2-mod-passenger
>apt install libssl-dev
>apt install libpq-dev
>apt install libxml2-dev
>apt install libxslt-dev
>apt install libsqlite3-dev

# if you use MySQL database
>apt install libmysqlclient-dev

#if you use Maria database
>apt install libmariadbd-dev # for de server, the last letter d means demon
>apt install libmariadb-dev # for the client


Just for informative purpose I noted down also the dependent packages which are automatically installed. This is handy to track problems due to missing packages on dependencies broken due to updates/upgrades

>apt install rubygems
# forces
# >apt install ruby2.7
# >apt install fonts-lato
# >apt install libruby2.7
# >apt install rake
# >apt install ruby-minitest
# >apt install ruby-net-telnet
# >apt install ruby-power-assert
# >apt install ruby-test-unit
# >apt install ruby-xmlrpc
# >apt install rubygems-integration
# and suggests
# >apt install ri
# >apt install ruby-dev

>apt install bundler
# forces
# >apt install libgmp-dev
# >apt install libgmpxx4ldbl
# >apt install ruby-bundler
# >apt install ruby-connection-pool
# >apt install ruby-dev
# >apt install ruby-molinillo
# >apt install ruby-net-http-persistent
# >apt install ruby-thor
# >apt install ruby2.7-dev
# >apt install ruby2.7-doc
# and suggests
# >apt install gmp-doc
# >apt install libgmp10-doc
# >apt install libmpfr-dev

>apt install thin
# forces
# >apt install ruby-daemons
# >apt install ruby-eventmachine

>apt install libapache2-mod-passenger
# forces
# >apt install passengerrake time:zones:local
# >apt install ruby-rack
# and suggests
# >apt install nodejs
# >apt install passenger-doc
# >apt install rails

Fix bundler

Unfortunately bundler is broken in the actual Ubuntu/Debian distribution. Follow the instructions at Ubuntu bundler broken due to ruby thor dependency - explanation and workaround to fix it.

Install Tracks

you can download a selected release from https://github.com/TracksApp/tracks/releases/

For this guide I will copy directly the files from the git repository.

go to the directory /var/www where Apache2 expects to have the websites (in Ubuntu, Debian flavors)

>cd /var/www

>git clone https://github.com/TracksApp/tracks.git

this will create the directory tracks and download the files from the github repository

Configure the parameter files

create the configuration file database.yml from the file database.yml.tmpl

create the configuration file site.yml from the file site.yml.tmpl

from inside the tracks directory

>cp ./config/database.yml.tmpl ./config/database.yml

>cp ./config/site.yml.tmpl ./config/site.yml

edit the content of database.yml

you can use the nano text editor

>nano database.yml

Normally you edit only the "production" section

the words in bold are the names you need to choose for the database, the user and password. This must match what you later use when manually create the database.

The adapter mysql2 is the one for MySQL or MariaDB

production:
adapter: mysql2
database: tempe
encoding : utf8
host: localhost
username: daniel
password: DaNiElPsW

edit the content of site.yml

you can use the nano text editor

>nano site.yml

Choose a new secret token and set the correct time zone

secret_token: 'change-me'
time_zone: 'UTC'
admin_email : my.email@domain.com

If you intend to use Tracks behind a web server or reverse proxy with https enabled, ensure to set force_ssl option to true.


For the time zone setting you can use the command

>rake --rakefile=/var/www/tracks/Rakefile time:zones:local
>bundle exec rake time:zones:local

to see all available timezones on your machine (you will be able to run this only after the installation of the 'gems' that takes place below)

Adjust owner and owner group for the downloaded files

All the files should be owned by the user ''www-data'' which is the user that runs Apache.

To set the owner and the owner group of all the files to www-data, at /var/www execute

>chown -R www-data:www-data tracks

then you need to set the access rights, the simplest way is at /var/www execute

>chmod -R 777 tracks

later once you have all running you can correctly set

> find /var/www/tracks -type d -exec chmod 700 '{}' \;
> find /var/www/tracks -type f -exec chmod 600 '{}' \;
> find /var/www/tracks/script -type f -exec chmod 700 '{}' \;

The ''find'' and ''chmod'' commands will set permissions as ''700'' for all directories and files inside the ''script'' directory.

All other files will have permissions set to ''600''.

Manually create the database

You need to create a database and database-user to use with Tracks, in this guide the name of the database is tempe, we create a user daniel with a password DaNiElPsW with all privileges to access the database

>mysql -u root -p
mysql> CREATE DATABASE tempe CHARACTER SET UTF8;
mysql> CREATE USER daniel@localhost IDENTIFIED WITH mysql_native_password BY 'DaNiElPsW';
mysql> GRANT USAGE ON *.* TO daniel@localhost;
mysql> GRANT ALL PRIVILEGES ON tempe .* TO daniel@localhost;
mysql> GRANT GRANT OPTION ON tempe .* TO daniel@localhost; # Enables you to grant to or revoke from other users those privileges that you yourself possess.
mysql>quit;

Note: for the dump of the database (using mysqldump) you need to add the global PROCESS privilege to the user running the command

mysql>GRANT PROCESS ON *.* TO daniel@localhost;

you can use the following to verify that the database and the user were created

mysql> SHOW DATABASES;
mysql> SELECT User FROM mysql.user;
mysql> quit

if needed you can restart the MySQL service

>systemctl restart mysql.service

you can use the following to check that MySQL is running ok

>systemctl status mysql.service

to explicitly change an already existent user to use mysql_native_password you can use these commands

mysql> ALTER USER 'daniel'@'localhost' IDENTIFIED WITH mysql_native_password BY 'DaNiElPsW';

mysql> FLUSH PRIVILEGES;

Install the required Ruby libraries known as ‘gems’

The Bundler tool makes it easy to install all the gems that Tracks needs, and ensures that they are all the correct versions.

go to the directory where you installed Tracks and run

>cd /var/www/tracks
>bundle config set without 'development test sqlite'
>bundle install

This can take some time depending on the speed of your internet connection and the speed of the system you are installing Tracks on.

later in time you can update with

>bundle update

Populate database

This will set up your database with the required structure to hold Tracks data.

going to the directory where Tracks is installed run

>cd /var/www/tracks
>rake --rakefile=/var/www/tracks/Rakefile db:migrate RAILS_ENV=production
>bundle exec rake db:migrate RAILS_ENV=production

If you get the error : "ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime", that means that yourJavaScript runtime has lost its magic or you don't have a JavaScript runtime installed.

When we installed "libapache2-mod-passenger" it suggested to install "nodejs"; so just install (or re-install) it."

>apt install nodejs

Precompile assets

Static assets (images, stylesheets, and javascript) need to be compiled in order for them to work correctly with the new asset pipeline feature in Rails.

going to the directory where Tracks is installed run

>cd /var/www/tracks
>rake --rakefile=/var/www/tracks/Rakefile assets:precompile RAILS_ENV=production
>bundle exec rake assets:precompile RAILS_ENV=production

Run Apache

Enable module rewrite

>a2enmod rewrite

Activate the new configuration

>systemctl restart apache2

you can check the status, to see that up to here everything is ok, with

>systemctl status apache2.service
>journalctl -xe

if apache was installed correctly and is running go with your browser to http://localhost you should see the Apache webserver page.

For more information see Apache tips

Setup Apache to run your website

at /etc/apache2/sites-available/ create the file tracks.conf

you can make a copy from 000-default.conf

Note:

The default/standard port for http is 80. As I already have a web site running on port 80 the next common choice is to use port 8080 where in my case is running a VNC then finally I selected the port 8079

If you go for the standard port 80 you need to use 80 where I refer to 8079 and you need to remove the symbolic link "000-default.conf" in /etc/apache2/sites-enabled to have only your Tracks web "enabled" and running for port 80.


Just for information the use of libapache2-mod-passenger makes Passenger in Apache to auto-detect the rails app


edit your website configuration file

>nano /etc/apache2/sites-available/tracks.conf

------------

<VirtualHost *:8079>
ServerName tracks.local

DocumentRoot /var/www/tracks/public
AcceptPathInfo on

ErrorDocument 403 "<h1>Site update in progress. Check back in a few minutes.</h1>"

<Directory /var/www/tracks/public>
Require all granted
AllowOverride All
</Directory>

## Logging
ErrorLog "/var/log/apache2/tracks_error.log"
ServerSignature Off
CustomLog "/var/log/apache2/tracks_access.log" combined
</VirtualHost>

------------

now edit the file /etc/apache2/ports.conf and add the Listen for port 8079

>nano /etc/apache2/ports.conf

------------

Listen 80
Listen 8079

<ifmodule ssl_module="">
Listen 443
</ifmodule>

<ifmodule mod_gnutls.c="">
Listen 443
</ifmodule> create link

------------

finally create a symbolic link so Apache services it

>cd /etc/apache2/sites-enabled
>ln -s ../sites-available/tracks.conf ./

restart Apache

>systemctl restart apache2

------------

log-files-locations

Good to know for debugging: by default the Passenger log file is the global (not the per-vhost) Apache error log file. This is typically located in /var/log/apache2/error_log. You can find out the exact location of the Passenger error log by running

>passenger-config --detect-apache2

Run Tracks

Congratulation! you are still alive and ready tu run Tracks for the first time!

You need to create and admin account first.

Open the URL http://localhost:8079/signup to start tracks for the first time

Later from the admin account you can create as many users as you want.

Note: this is NOT the same user as the MySQL user you defined for the database.

fill the fields with

user:daniel

pass:dAnIeL

If you need to access Tracks from a mobile/cellular phone browser, visit http://yourdomain.com/mobile/.

This mobile version is a special, lightweight version of Tracks, designed to use on a mobile browser.


Customise Tracks

Once logged in, add some Contexts and Projects, and then go ahead and add your actions. You might also want to visit the Preferences page to edit various settings to your liking.

------------

next time just connect using your internet browser to

http://localhost:8079/

or http://{ip of the machine with apache}:8079/

e.g. http://192.168.11.15:8079/

if you used port 80 you can go directly http://localhost/

------------

My calendar was in russian!!!

The problem is explained in this issue

https://github.com/TracksApp/tracks/issues/2553

I posted there a workaround.

Clone this wiki locally