MantisBT

出自 ArchWiki

MantisBT(Mantis Bug Tracker)是一个用 PHP 编写的缺陷跟踪器。有关功能列表,请访问其网站。

安装

安装 mantisbtAUR 软件包。

选择您喜欢的 Web 服务器 和/或应用服务器(例如 UWSGI)以使应用程序可用。

配置

mantisbt 有一份不错的管理指南,可以按照它进行设置。

所有配置都在 /etc/webapps/mantisbt/config_inc.php 中公开。

  • 设置兼容的 DBMS 并使用“数据库配置”部分将 mantisbt 与之连接。
  • 如果您不打算为新注册禁用 CAPTCHA(请参阅 #PHP 扩展#TTF 字体),则“匿名访问/注册”部分需要特别注意。
  • 如果您想使用 SMTP,可以在“电子邮件配置”部分进行设置。mantisbt 默认为 phpmailer 设置,其缺点是无法访问使用 灰名单 的邮件服务器。

在任何情况下,您都需要满足一些要求才能使 mantisbt 正常工作

PHP 扩展

TTF 字体

/etc/webapps/mantisbt/config_inc.php
# trailing slash is important!
$g_system_font_folder = '/usr/share/fonts/TTF/';

# here DroidSans.ttf from the package ttf-droid is used for illustration
$g_font_per_captcha = 'DroidSans.ttf';
注意: 确保还将 TTF 路径(例如 /usr/share/fonts/TTF)包含在 PHP 实例的 open_basedir 中!

Web 服务器

nginx + uwsgi

此示例显示了使用子域名进行错误跟踪的基本设置,以及一些手动重定向。下面提到的文件当然需要在 /etc/nginx/nginx.conf 中被引用。对于基于子文件夹的 mantisbt 设置,需要进行一些修改。

/etc/nginx/nginx.conf
server {
  listen 80;
  listen [::]:80;
  server_name bugs.mydomain.org www.mydomain.org;
  return 301 https://bugs.mydomain.org$request_uri;
}
server {
  listen 443 ssl;
  listen [::]:443 ssl;
  server_name www.bugs.mydomain.org;
  return 301 https://bugs.mydomain.org$request_uri;
}
server {
  listen 443 ssl;
  listen [::]:443 ssl;
  server_name bugs.mydomain.org;
  include tls.conf;
  root /usr/share/webapps/mantisbt;
  access_log /var/log/nginx/access.bugs.mydomain.log;
  error_log /var/log/nginx/error.bugs.mydomain.log;
  include letsencrypt-challenge.conf;

  location ~ ^/(admin|core|doc|lang) {
    deny all;
  }

  location / {
    index index.php;
    try_files $uri $uri/ @mantisbt;
  }

  location @mantisbt {
    include uwsgi_params;
    uwsgi_modifier1 14;
    uwsgi_pass unix:/run/uwsgi/mantisbt.sock;
  }

  location ~  \.php?$ {
    include uwsgi_params;
    uwsgi_modifier1 14;
    uwsgi_pass unix:/run/uwsgi/mantisbt.sock;
  }

  # Deny serving files beginning with a dot, but allow letsencrypt acme-challenge
  location ~ /\.(?!well-known/acme-challenge) {
    access_log off;
    log_not_found off;
    deny all;
  }
}

UWSGI 可以用于实现具有专用 PHP 设置的资源保留设置。

/etc/uwsgi/mantisbt.ini
[uwsgi]
procname-master = mantisbt
plugins = php
master = true
socket = /run/uwsgi/%n.sock
uid = http
gid = http
processes = 10
cheaper = 2
cheaper-step = 1
idle = 600
die-on-idle = true

php-allowed-ext = .php
php-docroot = /usr/share/webapps/mantisbt
php-index = index.php
php-set = date.timezone=Europe/Berlin
php-set = open_basedir=/tmp/:/usr/share/fonts/TTF:/usr/share/webapps/mantisbt:/usr/share/webapps/mantisbt/core:/etc/webapps/mantisbt
php-set = session.save_path=/tmp
php-set = session.gc_maxlifetime  21600
php-set = session.gc_divisor      500
php-set = session.gc_probability  1
php-set = post_max_size=64M
php-set = upload_max_filesize=64M
php-set = always_populate_raw_post_data=-1
php-set = extension=curl
php-set = extension=gd
php-set = extension=imagick
php-set = extension=intl
php-set = extension=mysqli

如果这些文件(修改后的版本)已就位,您应该重启您的 nginx 并使用 systemd 启动/启用 mantisbt 的 uwsgi 套接字。

数据库

在使应用程序可用后,使用 Web 浏览器转到 /admin/install.php 以设置数据库。按照该页面上的说明进行操作,并让 mantisbt 生成表。

注意: 您必须临时修改您的 #Web 服务器 设置才能访问该页面。这里根据使用 #nginx + uwsgi 的示例进行展示。
/etc/nginx/nginx.conf
  location ~ ^/(core|doc|lang) {
    deny all;
  }

管理员

mantisbt 生成的初始帐户名为 administrator,密码为 root

警告: 首次登录后,请务必立即更改 administrator 用户的密码并正确设置!
注意: 再次修改您的 #Web 服务器 设置,使 admin 设置再次不可用。使用 #nginx + uwsgi 的示例向您展示了如何操作。

用法

mantisbt 现在应该已全部设置完成。administrator 用户能够创建新项目并向注册用户授予用户权限。

参见