UNIT3D - How to install a Torrent Tracker

2nd May 2020 Karibu

Long time ago, I wrote some articles about Gazelle, a torrent tracker that became very popular for private trackers. The development has been long dead and many alternatives have emerged. One of them is Unit3D. Built on PHP Laravel, it is actively developped, modern and have a growing community of developers supporting the project.

The installation is relatively simple, since it used popular/standard technology and the community has prepared some scripts to support the installation. Unfortunately, this is for Ubuntu and won't work for Debian. So here is the manual installation for Debian 10 in my case.

Installation

They recommend obviously to have a recent and powerful enough server to handle such project. You will need Nginx, Php7.4, MySQL, a redis server, and some more dependencies (php-curl, etc..)

Basic requirements

Let's install all the requrements

sudo apt install git tmux vim curl wget zip unzip htop nano build-essential supervisor redis-server nginx

You will need to install MariaDB (or MySQL) in 10.2 version. In your repo, it might be the 10.1 version only (Debian 9 for example), in such case, you need to run the following:

sudo apt-get install software-properties-common dirmngr
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo nano /etc/apt/sources.list.d/mariadb.list

And add:

deb [arch=amd64,i386,ppc64el] http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.4/debian stretch main
deb-src http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.4/debian stretch main

Then install MariaDB

sudo apt update
sudo apt install mariadb-server

Once done, finalize the configuration of MariaDB

sudo mysql_secure_installation

and add a root password, and basic info.

Configure the database

You will need to have a dedicated database, to do it, simply run:

mysql -u root -p
CREATE USER 'unit3d'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE unit3d;
GRANT ALL PRIVILEGES ON unit3d.* TO 'unit3d'@'localhost';
FLUSH PRIVILEGES;
quit;

Modify the user/password by what you want.

Install PHP7.4 and NodeJS

In the repo, you probably have a less recent version of PHP. To use the 7.4, you will need to add the SURY PHP PPA repository

sudo apt -y install lsb-release apt-transport-https ca-certificates 
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update
sudo apt install php-pear php7.4-curl php7.4-dev php7.4-gd php7.4-mbstring php7.4-zip php7.4-mysql php7.4-xml php7.4-fpm php7.4-intl php7.4-bcmath

Now, install NodeJS and NPM and Laravel Echo Server

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt install nodejs
sudo npm install -g laravel-echo-server

Configure PHP-FPM

You need a slight modification here:

sudo nano /etc/php/7.4/fpm/php.ini

and find:

;cgi.fix_pathinfo=1

replace with

cgi.fix_pathinfo=0

Then restart it

sudo systemctl restart php7.4-fpm

Configure Nginx

You can adapt this part to your own configuration. If the server is dedicated for Unit3D, you can simply do:

sudo nano /etc/nginx/sites-available/default

and replace the content with

server {
    listen 80 default_server;
    root /var/www/html/UNIT3D;
    index index.html index.htm index.php;
    server_name yourdomain.com;
    location ~* \.(jpg|jpeg|png|gif|ico|svg)$ {
        expires 365d;
    }
    location ~ \.(gif|png|jpg|jpeg|svg|css|js|ico)$ {
        valid_referers none blocked yourdomain.com www.yourdomain.com;
        if ($invalid_referer) {
            return   403;
        }
    }
    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }
}

Don't forget to change the domain name.

And configure a SSL Certificate, using Let's Encrypt

sudo apt-get install certbot python-certbot-nginx
sudo certbot --nginx

Restart Nginx and you can proceed to the next part

sudo systemctl restart nginx

Install the latest version of UNIT3D

Download the latest version of the installer:

cd /var/www/html/
git clone https://github.com/HDInnovations/UNIT3D
cd UNIT3D
sudo chown -R www-data: storage bootstrap public config && sudo find . -type d -exec chmod 0755 '{}' + -or -type f -exec chmod 0644 '{}' +

And configure the .env

cp .env.example .env
nano .env

Fll it with your APP, DB, REDIS, API KEYS and MAIL info

Now install Composer and run the installer

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
composer install && composer require predis/predis && npm install && npm install --save-dev socket.io-client && npm run prod

This will take quite some time to download and isntall all the needed packages. Time for a coffee

Once done, with no issue, you are almost ready.

Setup Cron

sudo crontab -e

and add:

* * * * * php /var/www/html/UNIT3D/artisan schedule:run >> /dev/null 2>&1

Setup UNIT3D

To create the needed configuration and start it, you need to run:

php artisan key:generate
php artisan config:cache
php artisan migrate --seed
sudo chown -R www-data: storage bootstrap public config
laravel-echo-server init

You will have few questions to answer:

? Do you want to run this server in development mode? = No (Yes for debug or
developement)

? Which port would you like to serve from? = 8443

? Which database would you like to use to store presence channel members? =
redis

? Enter the host of your Laravel authentication server. =
https://yourdomain.com

? Will you be serving on http or https? = https

? Do you want to generate a client ID/Key for HTTP API? = Yes

? Do you want to setup cross domain access to the API? = No

It will ask the SSL Cert as well. It's probably here:

/etc/letsencrypt/live/domain/fullchain.pem
/etc/letsencrypt/live/domain/fullchain.pem

Configure the supervisor

sudo nano /etc/supervisor/conf.d/unit3d.conf

and add:

[program:unit3d-queue]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/UNIT3D/artisan queue:work --sleep=3 --tries=3
startsecs = 0
autostart=true
autorestart=true
user=www-data
numprocs=2

[program:unit3d-socket-io]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/node /usr/bin/laravel-echo-server start --dir=/var/www/html/UNIT3D
autostart=true
autorestart=true
user=www-data
numprocs=1

Load it and check it:

sudo supervisorctl reread && sudo supervisorctl update && sudo supervisorctl reload
sudo supervisorctl

Then reload it

sudo supervisorctl reload

And your UNIT3D private Tracker should be ready to welcome your first users!

The default user/password will be UNIT3D //// UNIT3D

Enjoy!

Gravatar

Loves to discover web-based apps to install on his own server@home and write articles about it

0 Comments:

Add a comment