How to deploy TestRail in Linux
背景:
TestRail为一个测试用例管理平台,其功能简单大方,但足够满足项目的测试用例库使用。
TestRail需要LAMP环境,官网提供了完整的LAMP环境配置文档,可参考:https://www.howtoforge.com/quick-n-easy-lamp-server-centos-rhel
LAMP部署精简就是下面几个步骤:
Install Apache
yum install httpd httpd-devel
/etc/init.d/httpd start
Install MySQL Database Server
yum install mysql mysql-server mysql-devel
/etc/init.d/mysqld start
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql> FLUSH PRIVILEGES;
Install PHP5 Scripting Language
yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
/etc/init.d/httpd restart
后面的phpMyAdmin,Webmin不是必须的,可以不安装。
TestRail安装步骤,参考官网提供的文档:http://docs.gurock.com/testrail-admin/installation-unix
创建数据库:
mysql>CREATE DATABASE testrail DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
mysql>CREATE USER 'testrail'@'127.0.0.1' IDENTIFIED BY 'zyLC021';
mysql>GRANT ALL ON testrail.* TO 'testrail'@'127.0.0.1';
mysql>FLUSH PRIVIGELES;
备注:
127.0.0.1 不能用 localhost 代替,否则在TestRail Setup Wizard 第二步会报错,数据库无法连接,如下图:
Installing TestRail
To install the actual application, just upload and extract the TestRail installation archive to your web server and copy the files to your web server'swwwdirectory (Centos: it's/var/www/html/testrail).
#cd /opt/
#mkdir testrail
#cd testrail
#mkdir attachments
#mkdir reports
#chmod apache:apache /opt/testrail/attachments
#chmod apache:apache /opt/testrail/reports
#mkdir /var/www/html/testrail/logs
#chmod apache:apache /var/www/html/testrail/logs
开始安装:
Activating the TestRail background task
The last step of the TestRail installation consists of installing the background task. The background task is responsible, among other things, for sending out email notifications for test changes if this feature is enabled. The background task needs to be triggered in regular intervals to do its work and the easiest way to do this under Unix-based systems is to add acronjob. If you are using an OS X based server system, you might want to consider using alaunchd scriptinstead.
Before scheduling the task, you can verify that the background task can be successfully started by running it manually from the command line:
$php /var/www/html/testail/task.php
Background task on Unix/Linux
We usecronto trigger the background task on Unix/Linux systems periodically. Before scheduling the task, you can verify that it can be successfully started by running it manually from the command line:
$ php /var/www/testrail/task.php
The TestRail background task automatically detects if it's already running, so it's best to trigger the task in very short intervals (such as every minute) for best results. To do this, make sure cron is installed on your system and create a file/etc/cron.d/testrailwith the following content:
* * * * * www-data /usr/bin/php /var/www/testrail/task.php
The cron job needs the PHP command line interface, which might already be installed on your system. You can test this by executing thephp -vcommand. If it's not already installed, install thephp5-clipackage or equivalent with your platform's package manager.
Please note:Also make sure to add the above mentioned PHP extensions to thephp-cli's PHP.ini if it doesn't use the web server's PHP.ini file. E.g., on Ubuntu systems, also add theioncubeextension to/etc/php5/cli/php.ini.