Ubuntu系统下安装MantisBT

简介

MantisBT是一个开放源代码问题追踪器,它在简单和强大之间提供了一种微妙的平衡。

官网: https://www.mantisbt.org/

安装PHP7.0

Ubuntu14.04下的默认源是PHP5.0,需要添加外部源

1
2
3
4
apt-get install software-properties-common
add-apt-repository ppa:ondrej/php
apt-get update
apt-get install php7.0

整合PHP和MYSQL

1
apt-get install php7.0-mysql

1.mysql账号密码

1
mysql -uroot -p

2.设置创建mantisbt用户

1
2
3
GRANT SELECT, INSERT,
UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES,
CREATE TEMPORARY TABLES, DROP, REFERENCES ON bugtracker.* TO mantisbt@localhost IDENTIFIED BY 'password';

3.刷新权限

1
FLUSH PRIVILEGES;

4.创建数据库

1
CREATE DATABASE bugtracker;

5.退出

1
quit

整合PHP和Apache

1
2
apt-get install libapache2-mod-php7.0
/etc/init.d/apache2 restart

1.编辑apache主配置文件/etc/apache2/apache2.conf,修改KeepAlive设置

1
KeepAlive Off

2.Apache默认的multi-processing模块(MPM ) 是一个event 模块,但是 php默认是使用 prefork模块,禁用event模块,启用prefork模块

1
2
a2dismod mpm_event
a2enmod mpm_prefork

下载安装PHPMailer

1.下载地址https://github.com/PHPMailer/PHPMailer

2.解压到mantisbt/library中改名为phpmailer

3.mantisbt/library/phpmailer根目录新建文件composer.json

1
2
3
4
5
{
"require": {
"phpmailer/phpmailer": "^6.0"
}
}

4.下载安装composer

  • Step 1:进入安装目录

    1
    cd /usr/local/bin
  • Step 2:下载并安装

    1
    curl -s https://getcomposer.org/installer | sudo php
  • Step 3:添加执行权限

    1
    chmod a+x composer.phar
  • Step 4:加入全局命令

    1
    mv composer.phar /usr/local/bin/composer
  • Step 5:查看版本号

    1
    composer --version

5.在mantisbt/library/phpmailer根目录

1
composer require phpmailer/phpmailer

接下来就会下载PHPMailer,出现少git和zip和unzip命令

6.安装git

1
apt-get install git

7.安装zip和unzip

1
apt-get install zip unzip

8.重新运行

1
composer require phpmailer/phpmailer

9.在mantisbt/config/config.ini.php中指定PHPMailer

1
2
$g_use_phpMailer = ON;
$g_phpMailer_path = './library/phpmailer/';

出现的问题

PHP mbstring extension is not enabled.

1
2
3
FATAL ERROR: PHP mbstring extension is not enabled.
MantisBT requires this extension for Unicode (UTF-8) support
http://www.php.net/manual/en/mbstring.installation.php

EDIT: Dylan Pierce has confirmed that you can already install some
PHP 7 extensions in the same way you would for PHP 5.
For mbstring in particular, you can execute:

1
apt-get install php7.0-mbstring

重启apache2

1
service apache2 restart

邮件发送失败

1
2
3
4
5
2018-05-15 07:58:48 SMTP NOTICE: EOF caught while checking if connected
SMTP Error: Could not authenticate.
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
2018-05-15 07:58:48 SERVER -> CLIENT:

在mantisbt/config/config.ini.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# --- Email Configuration ---
$g_phpMailer_method = PHPMAILER_METHOD_SMTP; # or PHPMAILER_METHOD_SMTP, PHPMAILER_METHOD_SENDMAIL
$g_smtp_host = 'smtp.qq.com'; # used with PHPMAILER_METHOD_SMTP
$g_smtp_port = '587';
$g_smtp_username = 'xxx@qq.com'; # used with PHPMAILER_METHOD_SMTP
$g_smtp_password = 'password'; # used with PHPMAILER_METHOD_SMTP
$g_administrator_email = 'xxx@qq.com';
$g_webmaster_email = 'xxx@qq.com';
$g_from_email = 'xxx@qq.com'; # the "From: " field in emails
$g_return_path_email = 'xxx@qq.com'; # the return address for bounced mail
$g_from_name = 'Mantis Bug Tracker';
$g_use_phpMailer = ON;
$g_phpMailer_path = './library/phpmailer/';
$g_email_receive_own = OFF;
$g_email_send_using_cronjob = OFF;
$g_smtp_connection_mode = 'tls'; # Can be 'ssl' or 'tls'

$g_log_level = LOG_EMAIL | LOG_EMAIL_RECIPIENT;
$g_log_destination = '/opt/email.log';

测试PHPMailer

用来测试PHPMailer是否可用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
use PHPMailer\PHPMailer\PHPMailer;
date_default_timezone_set('Etc/UTC');
require 'library/phpmailer/vendor/autoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'smtp.qq.com';
$mail->SMTPSecure = 'tls';
$mail->SMTPAutoTLS = false;
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = 'xxxx@qq.com';
$mail->Password = 'password';
$mail->setFrom('xxx@qq.com', 'First Last');
$mail->addReplyTo('xxx@qq.com', 'First Last');
$mail->addAddress('xxxx@qq.com', 'John Doe');
$mail->Subject = 'PHPMailer SMTP test';
$mail->Body = 'This is a plain-text message body ___';
if (!$mail->send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message sent!';
}

相关主题