How to Install TestLink on CentOS 7

Published on: Thu, Mar 9, 2017 at 6:02 pm EST
CentOS Server Apps Web Servers

TestLink is an open-source web based test management execution system. It enables quality assurance teams to create and manage their test cases as well as to organize them into test plans. These test plans allow team members to execute test cases and track test results dynamically.

In this tutorial, we will be installing TestLink version 1.9.16 (the latest version at the time this article was written) on CentOS 7.

Prerequisites

  • A CentOS 7 x64 server instance.
  • A sudo user.

I'll reference the main IP of my CentOS 7 server as 203.0.113.1.

Step 1: Update the system

Log in to your server via SSH using the sudo user to install epel, update the system, and restart to apply the updates.

sudo yum install epel-release -y
sudo yum update -y && sudo shutdown -r now

Step 2: Install a web server—Apache

sudo yum install httpd -y

It is recommended to remove/disable the Apache default welcome page in production environments.

sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf

Prevent Apache from listing web directory files to visitors:

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf

Start the Apache service and enable it to auto-start on boot

sudo systemctl start httpd.service
sudo systemctl enable httpd.service

Step 3: Install database software—MariaDB 10.1

As required by TestLink 1.9.16, you need to install MariaDB 10.1 or later on your system.

3.1 Create the MariaDB 10.1 YUM repo file

cat <<EOF | sudo tee -a /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.1 CentOS repository list - created 2017-01-14 03:11 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

3.2 Install MariaDB 10.1 using YUM

sudo yum install MariaDB-server MariaDB-client -y

3.3 Start the MariaDB service and set it as running at system startup

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

3.4 Secure the MariaDB installation

sudo /usr/bin/mysql_secure_installation

Answer questions on the screen as instructed below, and remember to use your own MariaDB root password:

  • Enter current password for root (enter for none): Just press the Enter button
  • Set root password? [Y/n]: Y
  • New password: your-root-password
  • Re-enter new password: your-root-password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]: Y
  • Reload privilege tables now? [Y/n]: Y

3.5 Create a MariaDB database for TestLink

Log into the MySQL shell as root:

mysql -u root -p

Type the MariaDB root password you set earlier and then press Enter.

In the MySQL shell, create a database testlink, a database user testlinkuser, and the database user's password yourpassword as follows.

Note: For security purposes, remember to replace the sample password yourpassword with your own password.

CREATE DATABASE testlink;
CREATE USER 'testlinkuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON testlink.* TO 'testlinkuser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Step 4: Install PHP 7.1 and some extensions

TestLink requires PHP 5.5 or later. In order to get better performance, we will install PHP 7.1 and all the necessary extension for TestLink as follows:

sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
sudo yum install mod_php71w php71w-mysqlnd php71w-common php71w-gd php71w-ldap php71w-cli php71w-mcrypt php71w-xml -y

We will need to modify PHP settings to meet TestLink’s requirements as follows:

sudo cp /etc/php.ini /etc/php.ini.bak
sudo sed -i "s/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 2880/" /etc/php.ini
sudo sed -i "s/max_execution_time = 30/max_execution_time = 120/" /etc/php.ini

5.1 Download the TestLink 1.9.16 archive from the official TestLink GitHub repo, and then unzip the archive to the /var/www/html directory:

cd
wget https://github.com/TestLinkOpenSourceTRMS/testlink-code/archive/1.9.16.tar.gz
sudo tar -zxvf 1.9.16.tar.gz -C /var/www/html
sudo chown -R apache:apache /var/www/html/testlink-code-1.9.16

5.2 Create a custom configuration file for TestLink:

sudo cp /var/www/html/testlink-code-1.9.16/custom_config.inc.php.example /var/www/html/testlink-code-1.9.16/custom_config.inc.php

5.3 Modify the custom TestLink configuration file:

Use the vi text editor to open this configuration file:

sudo vi /var/www/html/testlink-code-1.9.16/custom_config.inc.php

Find the following lines:

// $tlCfg->log_path = '/var/testlink-ga-testlink-code/logs/'; /* unix example */
// $g_repositoryPath = '/var/testlink-ga-testlink-code/upload_area/';  /* unix example */

Replace them with:

$tlCfg->log_path = '/var/www/html/testlink-code-1.9.16/logs/';
$g_repositoryPath = '/var/www/html/testlink-code-1.9.16/upload_area/';

Save and quit:

:wq!

5.4 Create a virtual host for TestLink:

cat <<EOF | sudo tee -a /etc/httpd/conf.d/testlink.conf
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/testlink-code-1.9.16/
ServerName testlink.example.com
ServerAlias www.testlink.example.com
<Directory /var/www/html/testlink-code-1.9.16/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/testlink.example.com-error_log
CustomLog /var/log/httpd/testlink.example.com-access_log common
</VirtualHost>
EOF

5.5 Restart Apache in order to apply all above settings:

sudo systemctl restart httpd.service

5.6 Modify firewall rules in order to allow web access:

sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload

5.7 Finishing the installation

When you visit http://203.0.113.1 for the first time, you will be presented with the TestLink installation wizard.

On the first page, Click the New installation link.

On the Acceptance of License page, check I agree to the terms set out in this license., and then click the Continue button.

On the Verification of System and configuration requirements page, make sure that all requirements (excluding requirements on Postgres and MSSQL) are satisfied, and then click the Continue button.

On the Database Configuration page, provide database configuration info as follows, and then click the Process TestLink Setup button to finish the installation:

  • Database Type: MySQL/MariaDB (5.6+ / 10.+)
  • Database host: localhost
  • Database name: testlink
  • Table prefix: <LEAVE IT EMPTY>
  • Database admin login: root
  • Database admin password: <your-MariaDB-root-password>
  • TestLink DB login: testlinkuser
  • TestLink DB password: yourpassword

You can point your web browser to http://203.0.113.1 to start using TestLink, and you need to use the default credentials below to log in:

  • Login Name: admin
  • Password: admin

Note: Remember to change your password after logging in.

5.8 Security measures after the installation:

For security purposes, you should restrict the apache user's permissions after the installation:

sudo chown -R root:root /var/www/html/testlink-code-1.9.16
sudo chown -R apache:apache /var/www/html/testlink-code-1.9.16/{gui,logs,upload_area}
sudo systemctl restart httpd.service

Additionally, you should remove the /var/www/html/testlink-code-1.9.16/install directory:

sudo rm -rf /var/www/html/testlink-code-1.9.16/install

That's it. Thanks for reading.

Want to contribute ?

You could earn up to $300 by adding new articles