TestRail: QA Test Case Management installation on Linux

By | 03/22/2019

TestRail – Test Case Management Software for QA and Development Teams.

Well – that’s all needed as a description)

Below – its installation on Debian Linux with NGINX, Let’s Encrypt, PHP-FPM, MariaDB, and Exim.

Project’s homepage – www.gurock.com/testrail

Installation official documentation – here>>>.

Setup will be on an AWS EC2.


Login to the EC2:

ssh admin@testrail.example.com -i bttrm-testrail-eu-west-1.pem

Update packages list and installed packages:

root@ip-172-31-25-137:/home/admin# apt update && apt upgrade

Let’s Encrypt

Install Let’s Encrypt client:

root@ip-172-31-25-137:/home/admin# apt install -y git unzip
root@ip-172-31-25-137:/home/admin# git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt

Obtain a certificate using the standalone authenticator:

root@ip-172-31-25-137:/home/admin# /opt/letsencrypt/letsencrypt-auto certonly -d testrail.example.com
1: Spin up a temporary webserver (standalone)
2: Place files in webroot directory (webroot)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1
- Congratulations! Your certificate and chain have been saved at:
Your key file has been saved at:
Your cert will expire on 2019-06-19.


Install NGINX:

root@ip-172-31-25-137:/home/admin# apt -y install nginx

Will configure it a bit later.


Add the PHP 7.2 repository:

root@ip-172-31-25-137:/home/admin# wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
root@ip-172-31-25-137:/home/admin# echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
deb https://packages.sury.org/php/ stretch main

Update the available packages list:

root@ip-172-31-25-137:/home/admin# apt update

Install PHP and necessary for the TestRail modules:

root@ip-172-31-25-137:/home/admin# apt -y install php7.2 php7.2-fpm php7.2-mysql php7.2-curl php7.2-json php7.2-mbstring php7.2-xml php7.2-zip

Find PHP configs:

root@ip-172-31-25-137:/home/admin# find /etc/ -name php.ini

Edit both /etc/php/7.2/fpm/php.ini and /etc/php/7.2/cli/php.ini and add libraries load:

ionCube install

Download its archive:

root@ip-172-31-25-137:/home/admin# cd /tmp/
root@ip-172-31-25-137:/tmp# wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz

Unpack it and move to the /opt:

root@ip-172-31-25-137:/tmp# tar xfpz ioncube_loaders_lin_x86-64.tar.gz
root@ip-172-31-25-137:/tmp# mv ioncube /opt/

Add zend_extension to both ini-files as in the example above:



NGINX virtual host configuration

Generate DF-key:

root@ip-172-31-25-137:/tmp# openssl dhparam -out /etc/nginx/dhparams.pem 2048

Add a virtual host config /etc/nginx/conf.d/testrail.example.com:

server {

    listen 80;
    server_name testrail.example.com;

    # Lets Encrypt Webroot
    location ~ /.well-known {
        root /var/www/html;
        allow all;

    location / {

        # office1
        allow 194.***.***.24/29;
        # office2
        allow 91.***.***.78/32;
        # arseny home
        allow 188.***.***.48/32;
        deny  all;

        return 301 https://testrail.example.com;

server {

    listen       443 ssl;
    server_name  testrail.example.com;

    root /var/www/testrail.example.com;

    access_log  /var/log/nginx/testrail.example.com-access.log;
    error_log /var/log/nginx/testrail.example.com-error.log warn;

    # office1
    allow 194.***.***.24/29;
    # office2
    allow 91.***.***.78/32;
    # arseny home
    allow 188.***.***.48/32;
    deny  all;

    ssl_certificate /etc/letsencrypt/live/testrail.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/testrail.example.com/privkey.pem;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;
    ssl_session_timeout 1d;
    ssl_stapling on;
    ssl_stapling_verify on;

    location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|otf|ttf)\$ {
        try_files \$uri =404;

    location / {
        try_files $uri $uri/ /index.php?$args;

    location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|js|woff)$ {
        access_log off;
        log_not_found off;
        expires max;

    location ~ \.php(?:/|$) {
        try_files $uri =404;
        fastcgi_pass unix:/run/php/testrail.example.com.sock;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
        fastcgi_index index.php;

Check syntax and reload config files:

root@ip-172-31-25-137:/tmp# nginx -t && service nginx reload

PHP-FPM configuration

Create a pool’s config file /etc/php/7.2/fpm/pool.d/testrail.example.com.conf:


user = www-data
group = www-data

listen = /run/php/testrail.example.com.sock

listen.owner = www-data
listen.group = www-data

pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M

Restart FPM and check if the new pool started:

root@ip-172-31-25-137:/tmp# service php7.2-fpm restart
root@ip-172-31-25-137:/tmp# ps aux | grep fpm
root     15008  0.5  2.7 400684 28368 ?        Ss   11:00   0:00 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf)
www-data 15010  0.0  0.6 400676  6904 ?        S    11:00   0:00 php-fpm: pool testrail.example.com
www-data 15011  0.0  0.6 400676  6904 ?        S    11:00   0:00 php-fpm: pool testrail.example.com
www-data 15012  0.0  0.6 400676  6904 ?        S    11:00   0:00 php-fpm: pool www
www-data 15013  0.0  0.6 400676  6904 ?        S    11:00   0:00 php-fpm: pool www
PHP test

Create a working directory:

root@ip-172-31-25-137:/tmp# mkdir -p /var/www/testrail.example.com

Create the /var/www/testrail.example.com/info.php file:


Check in a browser:


Install it:

root@ip-172-31-25-137:/tmp# apt -y install mariadb-server

Run initial config:

root@ip-172-31-25-137:/tmp# mysql_secure_installation

Create a database and user:

MariaDB [(none)]> CREATE DATABASE testrail DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL ON testrail.* TO 'testrail'@'localhost' identified by 'uo***8a';
Query OK, 0 rows affected (0.00 sec)

TestRail installation

Get your trial here>>>.

You’ll get an email with the download link and trial-key.

Download archive:

root@ip-172-31-25-137:/tmp# wget https://secure.gurock.com/downloads/testrail/testrail-latest-ion70.zip

Unpack it and move to the project’s directory:

root@ip-172-31-25-137:/tmp# unzip testrail-latest-ion70.zip
root@ip-172-31-25-137:/tmp# cp -r testrail/* /var/www/testrail.example.com/
root@ip-172-31-25-137:/tmp# chown -R www-data:www-data /var/www/testrail.example.com/

Open your URL in a browser and proceed with the installation there:

Configure the database connection details:

Create logs directory:

root@ip-172-31-25-137:/tmp# mkdir /var/www/testrail.example.com/logs
root@ip-172-31-25-137:/tmp# chown -R www-data:www-data /var/www/testrail.example.com/

Set your project’s details:

An email will be set later, skip it for now:

Add an admin user, the trial key was sent in an email:


Log in:

Cron jobs

Now – add a cronjob to run TestRail’s tasks.

Check if task.php works:

root@ip-172-31-25-137:/home/admin# php /var/www/testrail.example.com/task.php
root@ip-172-31-25-137:/home/admin# echo $?

If no errors here – it can be added to a crontab:

* * * * * www-data /usr/bin/php /var/www/testrail.example.com/task.php

Exim and email settings

To send emails – a local Exim will be used.

Install it:

root@ip-172-31-25-137:/home/admin# apt -y install exim4-base

Configure it:

root@ip-172-31-25-137:/home/admin# dpkg-reconfigure exim4-config

Check if email sending works:

root@ip-172-31-25-137:/home/admin# echo "Exim test" | mailx -s "Exim test" admin@example.com

Go to the TestRail admin page – Administration > Site Settings > Email: