Web自动化测试-服务端测试环境部署
by:授客
目录
操作系统环境:CentOS 6.5-x86_64
下载地址:http://www.centoscn.com/CentosSoft/iso/2013/1205/2196.html
注:安装时选择以Basic Server的方式安装
Mariadb下载地址
http://mirrors.opencas.cn/mariadb/mariadb-5.5.45/yum/centos6-amd64/rpms/
Apache下载地址
http://httpd.apache.org/download.cgi#apache24
pcre下载地址
apr下载地址
http://mirrors.cnnic.cn/apache/apr/
apr-util下载地址
http://mirrors.cnnic.cn/apache/
libxml2下载地址
http://download.chinaunix.net/download/0007000/6095.shtml
php下载地址
http://php.net/downloads.php#v5.6.12
文件列表如下:
网盘统一下载地址:http://pan.baidu.com/s/1sj1Lzw5
安装Mysql、Mariadb(笔者选择安装的是Mariadb 5.5.45
需要下载的rpm包如下
[root@localhost mnt]# ls | grep rpm
MariaDB-5.5.45-centos6-x86_64-client.rpm
MariaDB-5.5.45-centos6-x86_64-common.rpm
MariaDB-5.5.45-centos6-x86_64-compat.rpm
MariaDB-5.5.45-centos6-x86_64-devel.rpm
MariaDB-5.5.45-centos6-x86_64-server.rpm
MariaDB-5.5.45-centos6-x86_64-shared.rpm
MariaDB-5.5.45-centos6-x86_64-test.rpm
安装Mariadb
[root@localhost mnt]# rpm -iUvh MariaDB-*.rpm
参考文章“MariaDB Centos7 下安装MariaDB”
建库:
CREATE DATABASE `1dcq`
建表:
CREATE TABLE `pagesobject` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`P_Id` int(11) DEFAULT NULL,
`PageName` varchar(255) NOT NULL DEFAULT '',
`Html_open` varchar(10) DEFAULT 'true',
`PageDesc` varchar(100) DEFAULT NULL,
`isParent` tinyint(2) DEFAULT NULL COMMENT '如果是0表示文件夹,是1表示1个页面',
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=257 DEFAULT CHARSET=utf8
CREATE TABLE `page_elements` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`PageId` smallint(6) DEFAULT NULL,
`FieldOrder` int(11) DEFAULT NULL,
`ElementName` varchar(100) DEFAULT NULL,
`ElementSelector` varchar(300) DEFAULT NULL,
`ElementSelector02` varchar(300) DEFAULT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=utf8
CREATE TABLE `runtptask` (
`runClientId` int(11) NOT NULL AUTO_INCREMENT,
`tpid` varchar(11) DEFAULT NULL,
`isRunning` int(11) unsigned zerofill DEFAULT '00000000000',
`runClientPCName` varchar(100) DEFAULT NULL,
`runClientPCIP` varchar(50) DEFAULT NULL,
`lastRunTime` datetime DEFAULT NULL,
PRIMARY KEY (`runClientId`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8
CREATE TABLE `testcases` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`p_id` int(11) NOT NULL,
`test_name` varchar(255) NOT NULL DEFAULT '',
`Html_open` varchar(10) DEFAULT 'true',
`checked` varchar(8) DEFAULT NULL,
`testModule_name` varchar(255) NOT NULL DEFAULT '',
`test_desc` varchar(255) DEFAULT NULL,
`testdataParas` varchar(255) DEFAULT NULL,
`testdata_isexist` varchar(10) DEFAULT NULL,
`isTestCase` tinyint(1) DEFAULT '0',
`compFolderid` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8
CREATE TABLE `testcases_steps` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`TestcaseID` varchar(100) DEFAULT NULL,
`ElementId` varchar(50) DEFAULT NULL,
`Command` varchar(255) DEFAULT NULL,
`InParas` varchar(255) DEFAULT NULL,
`OutParas` varchar(255) DEFAULT NULL,
`StepOrder` int(11) DEFAULT NULL,
`compFolderid` int(11) DEFAULT NULL COMMENT '测试步骤中插入的操作组件的父级id',
`compid` int(11) DEFAULT NULL COMMENT '测试步骤中插入的操作组件的id',
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=679 DEFAULT CHARSET=utf8
CREATE TABLE `tc_ele_command` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`commandName` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`commandPara` varchar(60) CHARACTER SET utf8 DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
CREATE TABLE `testcase_runround` (
`id` int(255) NOT NULL AUTO_INCREMENT,
`test_round_name` varchar(255) DEFAULT NULL,
`testset_list` varchar(255) DEFAULT NULL,
`tcfolder_tc_list` varchar(2000) DEFAULT NULL,
`testcase_list` varchar(1000) DEFAULT NULL,
`round_desc` varchar(25) DEFAULT NULL,
`testplan_file` varchar(255) DEFAULT NULL,
`runningTestPlanUrl` varchar(100) DEFAULT NULL,
`browserRuningDrivers` varchar(20) DEFAULT NULL,
`latelyRuningTime` datetime DEFAULT NULL,
`onlyOneRuning_tc_list` varchar(255) DEFAULT NULL,
`project_name` varchar(255) DEFAULT NULL,
`project_version` varchar(255) DEFAULT NULL,
`project_id` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8
CREATE TABLE `testreporter` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`testplanId` varchar(255) NOT NULL DEFAULT '',
`testcaseList` varchar(255) DEFAULT NULL,
`testcasedataGroup` tinyint(3) DEFAULT NULL COMMENT '--无用列',
`tpRunedtcs` varchar(100) DEFAULT NULL COMMENT '此轮执行的测试用例',
`tpRunnedHistoryId` bigint(50) DEFAULT NULL COMMENT '运行历史id,后续自动清除大于2天的报告',
`onTime` datetime DEFAULT NULL COMMENT '发生的时间',
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8
CREATE TABLE `tprunnedhistory` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`tpId` varchar(255) DEFAULT NULL,
`tpRunnedHistoryId` bigint(50) DEFAULT NULL,
`willRunningTestcaseList` varchar(1000) DEFAULT NULL,
`runPassedTc_count` int(11) DEFAULT '0',
`runPassedTc` varchar(1000) DEFAULT '',
`runFailedTc` varchar(1000) DEFAULT '',
`tpRunnedHistoryNotes` varchar(100) DEFAULT NULL,
`onTime` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8
CREATE TABLE `tcrunnedhistory` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`tpId` varchar(255) DEFAULT NULL,
`tpRunnedHistoryId` bigint(50) DEFAULT NULL,
`willRunningTestcaseList` varchar(1000) DEFAULT NULL,
`runPassedTc_count` int(11) DEFAULT '0',
`runPassedTc` varchar(1000) DEFAULT '',
`runFailedTc` varchar(1000) DEFAULT '',
`tpRunnedHistoryNotes` varchar(100) DEFAULT NULL,
`onTime` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8
INSERT INTO `pagesobject`(P_id, test_name) VALUES(1, '根目录');
INSERT INTO `testcases`(p_id, test_name) VALUES(0, '根目录');
安装gcc-c++
[root@localhost mnt]# yum install gcc-c++
安装apr
[root@localhost mnt]# tar -xvzf apr-1.5.2.tar.gz
[root@localhost mnt]# cd apr-1.5.2
[root@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.5.2]# make && make install
安装apr-util
[root@localhost mnt]# tar -xvzf apr-util-1.5.4.tar.gz
[root@localhost apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhost apr-util-1.5.4]# make && make install
安装pcre
[root@localhost mnt]# tar -xvzf pcre-8.36.tar.gz
[root@localhost mnt]# cd pcre-8.36
[root@localhost pcre-8.36]# ./configure --prefix=/usr/local/pcre
……
[root@localhost pcre-8.36]#make && make install
安装Apache
[root@localhost tmp]# tar -xzvf httpd-2.4.16.tar.gz
[root@localhost tmp]# cd httpd-2.4.16
[root@localhost httpd-2.4.16]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
[root@localhost httpd-2.4.16]# make && make install
可在httpd.conf中进行一些自定义配置
[root@localhost httpd-2.4.16]# vim /usr/local/apache/conf/httpd.conf
编辑httpd.conf,设置'ServerName':把ServerName www.example.com:80改成自己需要的(可先注释,然后新增一行
[root@localhost httpd-2.4.16]# vim /usr/local/apache/conf/httpd.conf
如果未配置,启动时会报如下错误:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
启动
[root@localhost httpd-2.4.16]# /usr/local/apache/bin/apachectl -k start
注:停止Apache
[root@localhost httpd-2.4.16]# /usr/local/apache/bin/apachectl -k stop
防火墙开放80端口
[root@localhost tmp]# iptables -A INPUT -p tcp --dport 80 -j ACCEPT
[root@localhost tmp]# services iptables save
-bash: services: command not found
[root@localhost tmp]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[root@localhost tmp]# service iptables reload
iptables: Trying to reload firewall rules: [ OK ]
注意:不开放端口的话,访问http://192.168.30.80,可能会访问不了
浏览器访问http://192.168.30.80,可以访问了,OK
参考连接:
http://httpd.apache.org/docs/current/
安装函数依赖模块
[root@localhost tmp]# rpm -iUvh php-common-5.3.3-40.el6_6.x86_64.rpm
warning: php-common-5.3.3-40.el6_6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:php-common ########################################### [100%]
[root@localhost tmp]# rpm -iUvh php-mbstring-5.3.3-40.el6_6.x86_64.rpm
warning: php-mbstring-5.3.3-40.el6_6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:php-mbstring ########################################### [100%]
[root@localhost tmp]#
安装libxml2
[root@localhost mnt]# tar -xvzf libxml2-2.6.27.tar.gz
[root@localhost mnt]# cd libxml2-2.6.27
[root@localhost libxml2-2.6.27]# ./configure --prefix=/usr/local/libxml12
[root@localhost libxml2-2.6.27]# make && make install
注:
1.如果mysql是源码包安装的,加--with-mysql=mysql_installation_path
2.如果未安装libxml2,可能报如下错误:
configure: error: xml2-config not found. Please check your libxml2 installation.
安装php
[root@localhost mnt]# tar -xvzf php-5.6.12.tar.gz
[root@localhost tmp]#cd php-5.6.12
[root@localhost php-5.6.12]#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-libxml-dir=/usr/local/libxml12/ --with-mysql --enable-mbstring=all
注:
1、如果mysql是以rpm宝的形式安装的,直接--with-mysql,如果是源码包安装的,--with-mysql=mysql_installation_path,,笔者实践发现,没加--with-mysql,安装后不能加载mysql.dll
2、带--enable-mbstring=all是因为提供PHP框架需要使用该模块
说明:编译php时,可能还会遇到如下错误
Sorry, I cannot run apxs. ***
Sorry, I cannot run apxs. Possible reasons follow:
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
解决方法:将apxs所在目录(例中为/usr/local/apache/bin/)添加到PATH环境变量,并使环境变量生效即可。
[root@localhost php-5.6.12]# cp php.ini.dist /usr/local/php/lib/php.ini
注:如果没有php.ini.dist 则把php.ini-development php.ini-production中的任何一个重命名为php.ini.dist即可
配置 httpd.conf 让apache支持PHP
# vim /usr/local/apache/conf/httpd.conf
找到 AddType application/x-gzip .gz .tgz ,然后添加如下带背景颜色的内容(.前面有空格)
#################Added by laiyu##################
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
#################################################
#AddType application/x-gzip .tgz
修改改配置文件php.ini
首先要确保php.ini中extension_dir 为php扩展所在目录,然后找到如下内容
;extension=php_mysql.dll
;extension=php_mysqli.dll
把前面的分号去掉,改成如下,保存,重启Apache:
extension=php_mysql.dll
extension=php_mysqli.dll
注意:如果这里不修改,可能会导致无法连接mysql,类似如下,查看apahce日志,
[root@localhost logs]# cat error.log
[Sat Aug 22 01:11:50.502345 2015] [:error] [pid 28567:tid 140674563237632] [client 192.168.40.74:64189] PHP Fatal error: Call to undefined function mysql_connect() in /usr/local/apache/htdocs/1dcq/connect.php on line 9, referer: http://192.168.40.80/1dcq/framework/pagesObject.php
找到如下代码,去掉前面的分号,即取消注释,加载该模块。
; extension=php_mbstring.dll
找到display_errors = On,修改为display_errors = Off
重启Apache
[root@localhost php-5.6.12]# /usr/local/apache/bin/apachectl stop
[root@localhost php-5.6.12]# /usr/local/apache/bin/apachectl start
测试php是否成功安装
写一个php测试页info.php,放到Apache的htdocs目录下。
在浏览器中输入:服务器地址/info.php,如:http://192.168.30.80/info.php
如果可看到php版本,系统等相关信息则表示成功了
参考连接:
http://php.net/manual/zh/install.unix.apache.php
安装好后,可以把PHP代码“framework.zip”解压源码“framework.zip”解压,放入到/usr/local/apache/htdocs/目录下,编辑connect.php,进行相关配置
[root@localhost tmp]# unzip framework.zip
[root@localhost tmp]# mv 1dcq/ /usr/local/apache/htdocs/