当前位置 博文首页 > 好习惯成就伟大:Ubuntu系统下安装MantisBT

    好习惯成就伟大:Ubuntu系统下安装MantisBT

    作者:[db:作者] 时间:2021-06-23 15:12

    简介

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

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

    安装PHP7.0

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

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

    整合PHP和MYSQL?

    apt-get install php7.0-mysql

    1.mysql账号密码

    mysql -uroot -p

    2.设置创建mantisbt用户

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

    3.刷新权限

    FLUSH PRIVILEGES;

    4.创建数据库

    CREATE DATABASE bugtracker;

    5.退出

    quit

    整合PHP和Apache

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

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

    KeepAlive Off

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

    a2dismod mpm_event
    a2enmod mpm_prefork

    下载安装PHPMailer

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

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

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

    {
    	"require": {
    		"phpmailer/phpmailer": "^6.0"
    	}
    }

    4.下载安装composer

    • Step 1:进入安装目录

    cd /usr/local/bin

    • Step 2:下载并安装

    curl -s https://getcomposer.org/installer | sudo php

    • Step 3:添加执行权限

    chmod a+x composer.phar

    • Step 4:加入全局命令

    mv composer.phar /usr/local/bin/composer

    • Step 5:查看版本号

    composer --version

    5.在mantisbt/library/phpmailer根目录

    composer require phpmailer/phpmailer

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

    6.安装git

    apt-get install git

    7.安装zip和unzip

    apt-get install zip unzip

    8.重新运行

    composer require phpmailer/phpmailer

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

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

    出现的问题

    PHP mbstring extension is not enabled.

    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:

    apt-get install php7.0-mbstring

    重启apache2

    service apache2 restart

    邮件发送失败

    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

    $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是否可用

    use \;
    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!';
    }

    相关主题

    • https://www.mantisbt.org/?, MantisBT官网
    • https://github.com/PHPMailer/PHPMailer?, PHPMailer下载
    • https://askubuntu.com/questions/491629/how-to-install-php-mbstring-extension-in-ubuntu