ubuntu下安装配置mantis

来源:互联网 发布:网络诈骗定罪 编辑:程序博客网 时间:2024/05/09 14:45


1、apache服务器安装sudo apt-get install apache2

2、php5安装 sudo apt-get install  php5

3、apache和php5的关联 sudo apt-get install  libapache2-mod-php5

4、mysql的安装sudo apt-get install mysql-server 

然后配置一下mysql 假定用户名和密码都为root

5、mysql对php5的支持  sudo apt-get install php5-mysql

6、php文件测试,写一个php文件test.php放入/var/www文件夹中

vi /usr/local/apache/htdocs/test.php

文件内容为:

<?

       Phpinfo();

?>

重启apache服务器sudo /etc/init.d/apache2 restart

登陆http://localhost/test.php查看apache配置情况, 看到php的有关配置信息就证明成功了

7、下载mantis 地址为http://www.mantisbt.org/download.php,解压后放在/var/www文件夹中

8、修改apache配置文件,在/etc/apache2/httpd.conf中添加

AddType application/x-httpd-php .php

AddType application/x-httpd-php .html   

这样apache就可以解析php文件

9、修改php5配置文件,   在/etc/php5/apache2/php.ini下查找 ";extension=msql.so"将前面的分号删除

10、mysql数据库创http://localhost/mantis/admin/install.php

mysql数据库创过程中,如果遇到忘记mysql密码的情况,可以用以下方法解决:

$ service mysql start

$ /usr/bin/mysqld_safe --skip-grant-tables &
就可以不需要密码就进入 MySQL 了。
$ mysql
>use mysql
>update user set password=password("your_passwd") where user="root";
>flush privileges; 

$ service mysql restart


11、登录:http://localhost/mantis

用户名:administrator

密码:root


12、中文环境配置

修改mantis配置文件:/var/www/mantist/config_defaults_inc.php

查找其中$g_default_language将其值改为 'chinese_simplified'


13、配置邮箱环境

下载PHPMailer_v5.1http://phpmailer.sourceforge.net

解压此安装包后到/var/phpmailer

修改/var/www/mantis/config_inc.php文件:


# --- Email Configuration ---
$g_use_phpMailer        = ON;
$g_phpMailer_path = '/var/phpmailer';
$g_phpMailer_method             = PHPMAILER_METHOD_SMTP; #PHPMAILER_METHOD_MAIL; # or PHPMAILER_METHOD_SMTP, PHPMAILER_METHOD_SENDMAIL
$g_smtp_host                    = 'smtp.demo.cn';                       # used with PHPMAILER_METHOD_SMTP
$g_smtp_username                = 'abc@demo.cn';                                        # used with PHPMAILER_METHOD_SMTP
$g_smtp_password                = '123';                                       # used with PHPMAILER_METHOD_SMTP
$g_administrator_email  = 'abc@demo.cn';
$g_webmaster_email      = 'abc@demo.cn';
$g_from_name                    = 'Mantis Bug Tracker';
$g_from_email           = 'abc@demo.cn';        # the "From: " field in emails
$g_return_path_email    = 'abc@demo.cn';        # the return address for bounced mail
$g_email_receive_own    = OFF;
$g_email_send_using_cronjob = OFF;

重启apache:

sudo /etc/init.d/apache2 restart


14、上传文件设置与存放路径

修改config_inc.php,增加:

$g_allow_file_upload   = ON;

$g_file_upload_method = DISK;

$g_preview_attachments_inline_max_size = 5 * 1024 * 1024; #5M

$g_max_file_size                = 10 * 1024 * 1024;      # in bytes


在mantis下创建一个目录 如 upload

设置权限, chmod -R 777 upload


修改每个项目下的上传文件存放路径,例如:  upload/


15、安装配置jpgraph

15.1 安装jpgraph库(jpgraph-2.3.4.tar.gz)http://www.aditus.nu/jpgraph/jpdownload.php

tar –zxvf  jpgraph-2.3.4.tar.gz

拷贝解压后 jpgraph到mantis/library/jpgraph目录下,注意修改目录权限与同级其他目录一致。

安装php5-gd

  sudo apt-get install php5-gd


15.2 配置config_inc.php

打开 /mantis/config_inc.php文件

添加 $g_graph_font = 'chinese_gbk';

添加  $g_use_jpgraph   = ON;

$g_jpgraph_path   =’library/jpgraph/’; //引号内添加jpgraph的位置


15.3 安装字体

ubuntu系统有些中文字体是不存在的,有两种方案可以解决。I 如果是本地服务器,可将需要的字体安装在本地系统字体目录下;II 如果是远程租用服务器,没有修改服务器本地配置的权限的时候,可以将字体拷贝到具有访问权限的某个目录下,然后修改jpgraph的源码

<jpg-config.inc.php需要修改一处

//DEFINE("TTF_DIR","/usr/X11R6/lib/X11/fonts/truetype/"); #改成

DEFINE("TTF_DIR","$SystemRoot/fonts/"); #fonts后面一定要带"/"


一般情况需要把下面几个字库安装到/usr/share/fonts/truetype/

arialbd.ttf  arial.ttf  simhei.ttf  simsun.ttc


15.4 jpgraph1.1.8之前的版本配置

1). 可以在http://www.aditus.nu/jpgraph/jpdownload.php下载最新版的JPGraph,请注意JPGraph 1.x 版本是针对php4,2.x 是针对php5的,请下载对应版本。

2). 将下载包解压到一个目录下,我解压到mantis下的jpgraph目录,定义为$JPGraph。

3). 然后在config_inc.php中添加下面几行:

$g_use_jpgraph = ON;

$g_jpgraph_path = './jpgraph/src/';       //你也可以按照你的地址填写文件的绝对路径。

4). JPGraph的中文显示

a) 如果你的界面语言是用简体中文或者繁体中文,那么你会看到图形中的汉字都是乱码,这是因为Mantis对于JPGraph的编码设置不正确造成的。

JPGraph会自动将汉字转换为UTF-8编码,但是需要在调用JPGraph的时候对标题等SetFont,Mantis没有做这个操作,因此汉字显示出来都是乱码。

解决方法是增加对图形设置字体的代码;

b) 打开$mantis/core/graph_api.php,查找:graph_get_font(),在其中添加一行

'chinese_gbk' => FF_SIMSUN,

c) 在config_inc.php文件中添加

$g_graph_font           = 'chinese_gbk';

d) 打开$JPGraph/src/jpg-config.inc.php

查找 DEFINE('CHINESE_TTF_FONT','bkai00mp.ttf');

改为 DEFINE('CHINESE_TTF_FONT','simsun.ttc');

jpg-config.inc.php也可以不改,如果生成的图形中的字体想由自己定义,可以这样改。

这个时候,如果你选择的语言是chinese_simplified,现在你的图形报表应该就可以显示中文了。

e) 但如果你选择语言跟我一样是chinese_simplified_utf8,则发现报表显示还是乱码。

原来JPGraph中处理的时候比较bt,只要看到字体设置是FF_SIMSUN,就认为字符串编码是GB2312,输出的时候都要转成UTF8,

单实际上已经是UTF8了,根本不用转。

直接修改代码:

打开JPGraph下的jpgraph.php文件,搜索其中:

elseif( $aFF === FF_SIMSUN ) {

      // Do Chinese conversion

      if( $this->g2312 == null ) {

   include_once 'jpgraph_gb2312.php' ;

   $this->g2312 = new GB2312toUTF8();

      }

      return $this->g2312->gb2utf8($aTxt);

}

改为:

elseif( $aFF === FF_SIMSUN ) {

      // Do Chinese conversion

   /*

      if( $this->g2312 == null ) {

   include_once 'jpgraph_gb2312.php' ;

   $this->g2312 = new GB2312toUTF8();

      }

      return $this->g2312->gb2utf8($aTxt);

   */

   return $aTxt;

}

就是把转换编码的代码注释掉,最好不要直接删掉了,不然以后想改回来就麻烦了。

这样改实际是有些问题,如果mantis中有部分用户的语言选择为chinese_simplified,另一部分选择为chinese_simplified_utf8就不行了,

默认情况下只有管理员和经理才能看到报表,如果让所有人都能看到报表需要将config_defaults_inc.php的$g_view_summary_threshold = MANAGER;修改为$g_view_summary_threshold = ANYBODY;


15.5 JpGraph 1.1.8之后的版本安装配置

默认的系统使用自己绑定的mantis graph, 我们也可以选择安装使用jpgraph。

1)、安装JPGRAPH及改程序

  a)安装:JpGraph, 从http://www.aditus.nu/jpgraph/jpdownload.php下载最新版本,记得看清对应的PHP版本。解压缩其中子目录src至mantis/library目录下,改名为jpgraph

  b)修改文件mantis/library/jpgraph/jpgraph_ttf.inc.php:

       elseif( $aFF === FF_SIMSUN ) {

            // Do Chinese conversion

            if( $this->g2312 == null ) {

                include_once 'jpgraph_gb2312.php' ;

                $this->g2312 = new GB2312toUTF8();

            }

            return $this->g2312->gb2utf8($aTxt);

        }

  改为

       elseif( $aFF === FF_SIMSUN ) {

            // Do Chinese conversion

        return $aTxt;

        }

2)、后台设置:

  a)安装插件:管理--》管理插件--》安装MantisGraph插件

  b)修改程序:

  *文件mantis/plugins/MantisGraph/pages/config.php

$t_current_font_selected = array(

        'simsun' => false,  //增加这一行

        'arial' => false,

//--------------------------------------

        Sans-serif:<br />

        <label><input type="radio" name="font" value="simsun"<?php echo print_font_checked( 'simsun' )?>/>宋体</label><br /> //增加这一行

        <label><input type="radio" name="font" value="arial"<?php echo print_font_checked( 'arial' )?>/>Arial</label><br />

//---------------------------------------------------------------------

   *文件mantis/plugins/MantisGraph/pages/config_edit.php:

if ( plugin_config_get( 'font' ) != $f_font ) {

        switch ( $f_font ) {

                case 'simsun':    //增加这一行

                case 'arial':

//----------------------------------------------------------------------

   *文件mantis/plugins/MantisGraph/core/graph_api.php:

                $t_font_map = array(

                        'simsun' => FF_SIMSUN,   //增加这一行

                        'arial' => FF_ARIAL,

3)、设置并启用:

  a)管理--》管理插件--》点击“MantisGraph 1.0”名字进入设置界面,

  b)Graph library to use选择“Jpgraph”,Font选择“宋体”

  c)点击“更改配置”后再看看统计报表中内容即可。


16. 打开新闻功能

修改config_inc.php

添加 $g_news_enabled = ON;