Centos6.5安装配置Mantisbt

一、安装配置Apache

1.1.安装依赖包(APR,APR-UTIL,pcre)

 tar -zxf apr-1.4.5.tar.gz
[root@ apr-1.4.5]# ./configure --prefix=/usr/local/apr
[root@ apr-1.4.5]# make
[root@ apr-1.4.5]# make install

[root@ ]# tar -zxf apr-util-1.3.12.tar.gz
[root@ apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
[root@apr-util-1.3.12]# make
[root@apr-util-1.3.12]# make install

#unzip -o pcre-8.10.zip
#cd pcre-8.10
#./configure --prefix=/usr/local/pcre
#make
#make install

1.2.编译安装Apache(安装包的获取:http://www.apache.org

tar -zxf httpd-2.4.10.tar.gz
#./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-#pcre=/usr/local/pcre

#make
#make install

1.3.配置Apache

vi /usr/local/apache/conf/httpd.conf
找到下面这行
#ServerName www.example.com:80
修改为:
ServerName www.服务器IP:80
保存退出。

1.4.拷贝文件
cp –a /usr/local/apache/bin/apachectl /etc/init.d/httpd

运行service命令
Service httpd restart

检验配置是否成功
IE地址栏输入:http://服务器IP:80
看到It’s Work证明配置成功。
或者使用 ps –aux|grep httpd
如果看到多行数据,也证明配置成功

 

二、安装Mysql(见本博客文章“centos6.5编译安装mysql5.6.20”)

 

三、安装GD库(让PHP支持GIF、PNG、JPEG)

注意:不安装只会影响mantis的数据统计部分功能。

3.1.安装jpeg6(jpegsrc.v6b.tar.gz)ftp://ftp.uu.net/graphics/jpeg/     

mkdir -p /usr/local/jpeg6

mkdir -p /usr/local/jpeg6/bin

mkdir -p /usr/local/jpeg6/lib

mkdir -p /usr/local/jpeg6/include

mkdir -p /usr/local/jpeg6/man

mkdir -p /usr/local/jpeg6/man1

mkdir -p /usr/local/jpeg6/man/man1

tar –zxvf  jpegsrc.v6b.tar.gz

./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static

报错,解决方法如下:

yum -y install libtool

然后进入jpeg-6b的源码目录,然后执行以下步骤,切记!COPY到当前目录注意后面的点(.)
#cd jpeg
#cp /usr/share/libtool/config/config.sub .
#cp /usr/share/libtool/config/config.guess .
也就是把 libtool里面的两个配置文件拿来覆盖掉jpeg-6b目录下的对应文件
make clean 再重新configure(切记必须重新configure,否则仍会报错)
没有权限的时候先建立对应的文件夹,再次make install就行了

./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static
make
make install

3.2.安装libpng(libpng-1.2.35-i486-1.gz) http://www.libpng.org/pub/png/libpng.html

tar –zxvf  libpng-1.2.35-i486-1.gz

./configure --prefix=/usr/local/libpng/

Make &&make install

3.3.安装freetype(freetype-2.3.9.tar.gz) http://freetype.fis.uniroma2.it/download.html

注意:需升级make version到3.80以上:下载地址:http://ftp.gnu.org/pub/gnu/make/

tar –zxvf  freetype-2.3.9.tar.gz

mkdir -p /usr/local/freetype

./configure --prefix=/usr/local/freetype

Make &&make install

3.4.安装zlib (zlib-1.2.3.tar.gz) http://zlib.net/index.html
tar –zxvf  zlib-1.2.3.tar.gz
./configure --prefix=/usr/local/zlib
Make &&make install

3.5.安装GD库 (gd-2.0.35.tar.gz) http://www.libgd.org/Downloads
注意:需要对m4升级到1.4.12. 下载地址:http://ftp.gnu.org/pub/gnu/m4/
注意:需要对autoconf升级到2.58或者更高 下载地址:http://ftp.gnu.org/pub/gnu/autoconf/
tar –zxvf  gd-2.0.35.tar.gz
mkdir -p /usr/local/gd2
./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6 --with-png=/usr/local/libpng --with-zlib=/usr/local/zlib --with-freetype=/usr/local/freetype
Make &&make install

3.6.安装Curl库(curl-7.19.4.tar.gz) http://curl.haxx.se/download.html
tar –zxvf  curl-7.19.4.tar.gz
./configure --prefix=/usr/local/curl
Make &&make install

 

四、安装PHP5.3.9(PHP必须有libxml2支持)
安装包的获取:http://www.php.net

4.1.安装libxml2
cd libxml2-2.7.8
./configure --prefix=/usr/local/libxml2

4.2.安装libxslt-1.1.24(可选安装)
yum -y install python-devel依赖包
yum -y install libgcrypt-devel依赖包
cd libxslt-1.1.28
./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2

4.3.安装php5
tar –zxvf php-5.3.9.tar.gz
./configure --prefix=/usr/local/php --with-mysql=/hywl/mysql --with-apxs2=/usr/local/apache/bin/apxs --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg6 --with-png-dir=/usr/local/libpng --with-zlib-dir=/usr/local/zlib --with-freetype-dir=/usr/local/freetype --with-curl=/usr/local/curl --with-xsl=/usr/local/libxslt --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-sockets --with-openssl
make && make install
如果出现以下错误:
/usr/local/jpeg/include/jpeglib.h:938: error: expected declaration specifiers or ‘...’ before ‘FILE’
/usr/local/jpeg/include/jpeglib.h:939: error: expected declaration specifiers or ‘...’ before ‘FILE’
make: *** [ext/gd/libgd/gd_compat.lo] Error 1
解决办法:
修改 php-5.3.9/ext/gd/libgd/gd_compat.c
1.把 <png.h> 改成绝对路径</usr/local/libpng/include/png.h>(这个在编译gd库的时候应该就碰到了,同样的路径即可)
2.并在 # include <jpeglib.h> 前面增加一行 #include <stdio.h>     
然后 make clean
重新 configure、make、make install就可以了

4.4配置文件
#cp php.ini-recommended /usr/local/php/lib/php.ini

 

五、新配置Apache

5.1. vi /usr/local/apache/conf/httpd.conf
找到 AddType application/x-gzip .gz .tgz在其下面添加一行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

找到  DirectoryIndex index.html修改为:
DirectoryIndex index.html default.php index.php

5.2设置php文件
Vi /usr/local/php/lib/php.ini
找到register-globals这一行修改成:
register-globals=on
修改如下语句:
date.timezone = "Asia/Shanghai"

5.3第一个php程序
vi /usr/local/apache/htdocs/test.php
文件内容为:

<?php

Phpinfo();

?>

5.4重启apache服务
service httpd restart
5.5检验是否成功
在IE中输入如下网址
http://服务器IP/test.php
看到php的有关配置信息就证明成功了。

 

六、安装mantis

6.1将mantis解压到/usr/local/apache/htdocs目录下。
重命名:mv mantisbt-1.2.17  mantisbt
修改权限:chmod 755 mantisbt

6.2生成数据库;

创建数据库mantis,并对相应的用户分配权限。
mysql> create database mantis default character set utf8 collate utf8_general_ci;
grant all privileges on mantis.* to 'mantis'@'%' identified by 'mantis';
grant all privileges on mantis.* to 'root'@'%' identified by 'sqlroot' with grant option;

打开网页http://服务器IP/mantis/admin/install.phpwKiom1QqM46yfWwsAAQvFUNcp8Y614.jpg

Type of Database:   默认数据库是MySQL
Hostname (for Database Server):   MySQL装在本机,可以默认
Username (for Database)   : 数据库的用户名(刚才创建的用户名和密码)
Password (for Database)   : 数据库的用户名密码(刚才创建的用户名和密码)
Database name (for Database)       刚才创建的数据库名mantis
Admin Username (to create Database ifrequired):   数据库管理员用户名及密码
Admin Password (to create Database ifrequired):   数据库管理员用户名及密码
Print SQL Queries instead of Writing to theDatabase    选上此项,输出SQL但不写到数据库,因为输出的SQL语句中要修改
点击install/Upgrade Database

wKioL1QqJz2Dy-0YAAYiEOiyIfw013.jpg

wKioL1QqJz7RrDHLAAcLl7f1MPo505.jpg

将上图页面中的Installing Database部分拷出来
删掉Database Creation Suppressed, SQL Queries follow
删掉SYSTEM WARNING: Invalid argument supplied for foreach()
修改language       VARCHAR(32) NOT NULL DEFAULT 'english',
为   language      VARCHAR(32) NOT NULL DEFAULT 'chinese_simplified',
保存为mantis_init_db.sql

以mantis用户登录mysql
mysql> use mantis
mysql> source /home/XXX/mantis_init_db.sql
完成数据库的建立
此时再次按照刚才的方式填写,执行install/Upgrade Database(可以不执行,仅是检查数据库建立是否正确)wKiom1QqJxPBR-rJAARZTdYcHpQ415.jpg

 

七、配置mantis

7.1在mantis目录下新建配置文件config_inc.php

配置文件加载顺序:先加载config_defaults_inc.php,后加载config_inc.php。config_inc.php中的值会覆盖config_defaults_inc.php

此处只是简单写了下配置文件,各参数含义以及详细配置可以参看config_defaults_inc.php,如果要修改,建议拷到config_inc.php中修改。

$ cp config_inc.php.simple config_inc.php
然后修改

# --- Database Configuration ---
$g_hostname      = '服务器IP';
$g_db_username   = 'mantis';
$g_db_password   = '密码';
$g_database_name= 'mantis';
$g_db_type       = 'mysql'; 

 

Mantis邮箱配置,在新版的Mantis配置里面默认通过接收激活邮件来设定用户密码。
注册新用户时同时可以绕过邮箱验证:
在Mantis目录下config_defaults_inc.php文件中找到$g_send_reset_password   =  ON
然后设置成:$g_send_reset_password = OFF  即可。
重新使用administrator账号及密码,登录mantis, 依次选择 管理 -> 用户管理 -> “创建用户”, 可以看到填写密码的输入框啦!

 

以下邮件部分没有完全配置好,待修改 

# ---Email Configuration ---
$g_phpMailer_method           = PHPMAILER_METHOD_SMTP;
$g_smtp_host                            = 'mail.xxx.com.cn:25';  
$g_smtp_username                 = 'xxx@xxxx.com.cn';                                 
$g_smtp_password                 = '密码'; 
$g_administrator_email = ' xxx@xxxx.com.cn ';
$g_webmaster_email     = ' xxx@xxxx.com.cn ';
$g_from_name                    = 'Mantis Bug Tracker';
$g_from_email          =  ' xxx@xxxx.com.cn ';        #the "From: " field in emails
$g_return_path_email   =  ' xxx@xxxx.com.cn';  # thereturn address for bounced mail
$g_email_receive_own    =  OFF;
$g_email_send_using_cronjob = OFF;
$g_enable_email_notification = ON;

图形统计部分还没有配置,待修改

最后增加一句设置语言为中文
$g_default_language= 'chinese_simplified';

7.2浏览器中输入http://服务器IP/mantisbt/
自动会跳转到登录页面
默认的用户名是administrator,密码是root
然后可以修改管理员密码,并将mantisbt下的admin目录移除。

 

八.常见问题与解决方法

8.1Mantis提交缺陷时超慢的原因和解决办法

Mantis安装或者使用一段时间后提交问题、添加注释、修改状态等操作时页面响应超慢,很简单的缺陷不添加附件的情况下都需要5s左右的时间才会提交成功,同时提交问题、添加注释、修改状态等操作后均无邮件提醒。 如果出现以上情况,可以确定是由于mantis的邮件发送出现问题导致数据库负担加重,写入数据时间过长,Mantis访问越来越慢。

解决问题:
 很多情况下Mantis都是默认发送邮件,如果Mantis里面的用户和项目过多且操作频繁时就会有大量的邮件数据产生并写入数据库 Mantis数据库(默认:bugtracker)存储Email的表:mantis_email_table
 
所有待发送的邮件都存在该表中,该表具有如下性质:
1. 如果邮件发送成功,表内数据将被自动删除
2. 如果邮件没有发送成功,或者没有清理成功,就会造成表 mantis_email_table内数据的堆积。这样会造提交时响应延迟
 测试Mantis邮件发送:
1. 退出mantis登录用户,点击‘忘记密码
2. 填写用户名和联系邮箱

3. 登录邮箱查看是否接受到邮件
如果没有接受到邮件可以判断是Mantis的邮件发送出现问题,导致了全部的邮件提醒滞留在mantis_email_table中
4. 查看mantis_email_table
  mysql>select * from mantis_email_table;

可以看到该表中存在大量的数据(实际查看时已经超过3000条)
删除表中全部数据(如果重要也可以不删除,恢复发送邮件功能会自动发送)
mysql>truncate table mantis_email_table;


 修改Mantis的邮箱配置
***/mantis/config_default_inc.php
 
1.只需要将相应的邮箱修改为正确的邮箱保存设置;

重启Mantis,提交缺陷此时有邮件提醒即可,如果之前未删除数据库会陆续收到数据库表中全部的邮件

2.或者将邮件发送开关关闭:$g_enable_email_notification    = OFF;

如果进行以上操作Mantis仍然访问慢,请检查下列设置:
 **/mantis/core/email_api.php
函数email_send()负责邮件发送,检查函数email_send() 中邮件发送和邮件删除功能是否正常
 修改PHP配置文件的memory_limit(默认为8M,可以修改为128M)