如何在 CentOS 7 上安装 Bugzilla 5.0

这个 HowTo 将引导您在 CentOS 7 上安装 Bugzilla 5.0。Bugzilla 是由 Mozilla 基金会(开发着名的 Firefox 浏览器的组织)开发的高级错误跟踪系统。 Bugzilla 允许您跟踪应用程序中的缺陷和代码更改,从而轻松地在开发人员团队中进行沟通,并提交并查看修补程序。

CentOS 的先决条件

网络连接

您应该有一个最小的 CentOS 7 安装,最新的更新和 IP 地址和主机名设置。 您的机器应该能够到达互联网。 如果您无法直接访问互联网,并且必须使用代理服务器,则应通过编辑 /etc/yum.conf 将 yum 配置为使用代理。 添加以下行(将它们更改为您的需要):

1
2
3
4
5
# The proxy server - proxy server:port
proxy=http://192.168.178.1:8080
# The account details for yum connections
# proxy_username=yum-user
# proxy_password=qwerty

当我们使用需要互联网访问的命令行工具,并且您在代理服务器后面时,请确保在使用需要 Internet 连接的命令之前始终执行以下两个命令:

export http_proxy=http://192.168.178.1:8080/
export https_proxy=http://192.168.178.1:8080/

使用这种方法,即使您是代理服务器,您也可以使用此方法。

SELinux

安全增强的Linux(SELinux)是在内核中实现的强制访问控制(MAC)安全机制。 这是一个很好的安全机制,但它将破坏 Bugzilla,直到官方的 Bugzilla 5.0 rpm 包发布,也将配置 SELinux。 所以在这一点上我们将 SELinux 设置为允许模式。 在此模式下,SELinux 已启用,但不会执行安全策略。

禁用 SELinux

执行以下命令将 SELinux 模式从强制更改为允许。

sudo sed -i ‘s/^SELINUX=enforcing$/SELINUX=permissive/g’ /etc/selinux/config

该文件现在应该如下所示:

1
2
3
4
5
6
7
8
9
10
11
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

之后,重新启动机器。

用于安装的账号

如果没有明确说明,则本操作中的所有命令都将作为 CentOS 7 机器上的管理用户的用户“installer”执行,并允许使用“sudo”执行命令。

附加存储库

我们将需要许多不在官方 CentOS 存储库中的软件包,因此我们在 CentOS 框中启用了一个额外的存储库。

启用Epel存储库

执行以下命令以启用 epel 存储库。

sudo yum install deltarpm epel-release
sudo yum update

信息:从 epel 存储库安装第一个包时,您必须接受 epel GPG 密钥。

使用 mod_ssl 和 mod_perl 安装 Apache

sudo yum install httpd httpd-devel mod_ssl mod_ssl mod_perl mod_perl-devel

这将安装 Apache,mod_ssl,mod_perl 和 wget 与所有所需的依赖关系。

启用并启动 httpd.service

CentOS 7 使用 systemd,所以我们将启用和启动 Apache 的 ‘systemd’ 方式。

启动 httpd.service

sudo systemctl start httpd.service

检查 httpd.service 的状态

sudo systemctl status httpd.service

该命令告诉你,httpd.service 正在运行(有些行被删除)

1
2
3
4
5
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
Active: active (running) since Tue 2015-08-04 11:18:03 CEST; 6s ago
Main PID: 11930 (/usr/sbin/httpd)
...

永久启用 httpd.service

验证以上输出后,我们启用 httpd.service 进行自动启动:

sudo systemctl enable httpd.service

系统将自动创建一个符号链接,使 http.service 能够自动启动。

在本地防火墙中打开端口 80 以允许 HTTP 请求

CentOS 7 正在使用 FirewallD,因此我们必须使用 firewall-cmd 更改防火墙设置,以允许端口80(HTTP)上的传入连接。

1
2
3
4
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
# success
sudo firewall-cmd --reload
# success

测试 Apache Web 服务器

使用浏览器打开 http://ip-of-your-server/ (使用您的服务器的IP地址替换 ip-of-your-server)。 你应该看到 Apache 测试页面。 - Apache is working!

安装 MariaDB

CentOS 7 自带的是 MariaDB,而不是 MySQL。 MariaDB 是一个与 MySQL 相当的开放源代码。 要安装 MariaDB,请执行以下命令:

sudo yum install mariadb-server mariadb mariadb-devel php-mysql

在启动时使 MariaDB 自动启动

要在启动时自动启动 MariaDB,我们将其设置为与 httpd.service 相同的方式。 执行以下三个命令启动,检查状态并启用 MariaDB 作为永久服务:

sudo systemctl start mariadb.service
sudo systemctl status mariadb.service
sudo systemctl enable mariadb.service

设置 MariaDB root 密码

通过执行以下命令,在您的 MariaDB 服务器中打开一个 SQL 提示:

mysql -u root

您应该登陆 MariaDB 提示符。 在以下命令中,必须将 myrootpassword 替换为您要用于 MariaDB root 用户的密码!

MariaDB [ (none) ]> SET PASSWORD FOR ‘root‘@’localhost’ = PASSWORD(‘myrootpassword’);

1
Query OK, 0 rows affected (0.00 sec)

MariaDB [ (none) ]> \q

1
Bye

现在尝试,如果您可以使用 root 用户登录

mysql -u root -p
Enter password: myrootpassword

1
2
3
4
5
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.41-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [ (none) ]> \q

Bye

为 MariaDB 设置 max_allowed_pa​​ckets

Bugzilla 需要在 MariaDB 中配置的最小大小 ‘max_allowed_packet’’。 所以我们更改通用的MariaDB 配置,将 ‘max_allowed_packet’ 的大小设置为 4MBytes。

用你的编辑器打开 ‘/etc/my.cnf’,并在 ‘[mysqld]’ 部分下面添加以下行:

1
2
3
4
# Bugzilla
# maximum allowed size of an attachment upload
#change this if you need more!
max_allowed_packet=4M

之后,整个 ‘my.cnf’ 看起来像这样:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
# Bugzilla
# maximum allowed size of an attachment upload
#change this if you need more!
max_allowed_packet=4M
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

这些更改将在重新启动 MariaDB 后生效。

sudo systemctl restart mariadb.service

附加包

Bugzilla需要大量的附加软件包,主要是perl相关的,使perl模块工作的一些先决条件,以及能够下载和安装perl模块的设置。 因此我们安装所有必要的依赖项。 我们也确保,我们
不要安装perl-homedir软件包,因为这会破坏Bugzilla的安装。
(‘perl-homedir’ 将在用户文件夹中安装 perl 模块,这些 Bug 不能被 Bugzilla 访问,所以绝对不要安装!)
以下命令将确保未安装 perl-homedir,并将安装其他必需的软件包:

sudo yum install gcc gcc-c++ graphviz graphviz-devel patchutils gd gd-devel wget perl* -x perl-homedir

将安装约1300个包!

安装 Bugzilla

现在我们已经准备好了所有的准备工作,我们准备下载最新的 Bugzilla,为它创建数据库并做一些最终的设置。

为 Bugzilla 创建数据库

要在我们的 MariaDB 服务器上为 Bugzilla 创建数据库,我们必须再次打开 MariaDB 提示符:

mysql -u root -p
Enter password: myrootpassword

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.41-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

在 MariaDB 提示符下输入以下命令来创建数据库的“错误”,并允许用户的错误完全访问它。 (请将 “bugsuserpassword” 更改为您的密码!)

MariaDB [ (none) ]> create database bugs;

1
Query OK, 1 row affected (0.00 sec)

MariaDB [ (none) ]> grant all on bugs.* to bugs@localhost identified by ‘bugsuserpassword’;

1
Query OK, 0 row affected (0.00 sec)

MariaDB [ (none) ]> \q

Bye

下载并提取 Bugzilla

虽然有不同的选项来获取 BugZilla,我们使用 wget 下载 tarball 我们要得到稳定版本(5.0)。

cd
wget ‘https://ftp.mozilla.org/pub/mozilla.org/webtools/bugzilla-5.0.tar.gz'

下载完成后,我们提取存档:

tar -xzvf bugzilla-5.0.tar.gz

将 Bugzilla 文件夹复制到 webserver 文件夹

现在让我们使用以下命令将提取的文件夹(bugzilla-5.0)复制到目标场景 (/var/www/html/bugzilla)

cd
sudo cp -R ./bugzilla-5.0/ /var/www/html/bugzilla/

使用 Bugzilla 的安装脚本进行最终设置

以下命令必须作为 root 用户执行,因此我们使用以下命令打开 shell:

sudo su
[root@localhost installer]#

我们的提示现在已经结束了’#’,这意味着我们是 root 用户。 现在请注意所有命令! 现在,howto将始终显示提示告诉你,你应该是 root 用户来执行命令!
现在(以 root 用户身份),我们更改为 bugzilla 所在的 webserver 文件夹

[root@localhost installer]# cd /var/www/html/bugzilla
[root@localhost bugzilla]#

现在执行以下命令让 Bugzilla 安装脚本检查我们设置的状态

[root@localhost bugzilla]# ./checksetup.pl

通常,上述命令的输出将告诉我们,我们的安装(可选和必需的)中缺少一些perl模块,我们必须至少安装必需的模块才能继续。 您当然可以通过手动执行安装脚本将显示的命令来安装所有必需(如果您喜欢)可选模块,但是使用该命令,您将一次安装所有必需的 perl 模块(必需和可选)。 所以我们来执行它:

[root@localhost bugzilla]# /usr/bin/perl install-module.pl –all

安装脚本现在将设置一个临时 CPAN 配置,并尝试安装 Bugzilla 所需的所有 Perl 模块(必需和可选)。 在此过程中只会出现一些小小的警告。
最后,我们再次通过执行 checksetup.pl 来验证安装的状态

[root@localhost bugzilla]# ./checksetup.pl

除了一个模块(DBD-Oracle(v1.19),没有找到),所有依赖项都应该可以了,这是可以的,因为这个模块只有在找到一个我们没有的工作的 Oracle 安装时才会安装!
安装脚本现在将显示以下文本:

1
2
3
4
5
6
7
8
9
10
11
Reading ./localconfig...
This version of Bugzilla contains some variables that you may want to
change and adapt to your local settings. The following variables are
new to ./localconfig since you last ran checksetup.pl:
create_htaccess, webservergroup, use_suexec, db_driver, db_host,
db_name, db_user, db_pass, db_port, db_sock, db_check,
db_mysql_ssl_ca_file, db_mysql_ssl_ca_path, db_mysql_ssl_client_cert,
db_mysql_ssl_client_key, index_html, interdiffbin, diffpath,
site_wide_secret
Please edit the file ./localconfig and then re-run checksetup.pl
to complete your installation.

所以如上所述,我们用我们的编辑器打开 ./localconfig,并将其改为我们的需要。 这是我使用的(注释删除),确保你更改数据库的名称和密码,以满足您的需要!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$create_htaccess = 1;
$webservergroup = 'apache';
$use_suexec = 0;
$db_driver = 'mysql';
$db_host = 'localhost';
$db_name = 'bugs';
$db_user = 'bugs';
$db_pass = 'bugsuserpassword';
$db_port = 0;
$db_sock = '';
$db_check = 1;
$db_mysql_ssl_ca_file = '';
$db_mysql_ssl_ca_path = '';
$db_mysql_ssl_client_cert = '';
$db_mysql_ssl_client_key = '';
$index_html = 0;
$interdiffbin = '/bin/interdiff';
$diffpath = '/bin';
$site_wide_secret = 'ifKuihguW8nlxLcxeNU4whHzFbxDIGWSvtR6S7Ul38cFQn004YDcVzuBJfnF8M9X';

现在让我们再次运行安装脚本。 现在应该检测正确的数据库配置,并开始访问 MariaDB 服务器进行最终设置。

[root@localhost bugzilla]# ./checksetup.pl

Output (some lines stripped)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
...
Adding new table bz_schema...
Initializing bz_schema...
Creating tables...
Converting attach_data maximum size to 100G...
Setting up choices for standard drop-down fields:
priority bug_status rep_platform resolution bug_severity op_sys
Creating ./data directory...
...
...
Precompiling templates...done.
Fixing file permissions...
Initializing "Dependency Tree Changes" email_setting ...
Initializing "Product/Component Changes" email_setting ...
Marking closed bug statuses as such...
Creating default classification 'Unclassified'...
Setting up foreign keys...
Setting up the default status workflow...
Creating default groups...
Setting up user preferences...
Looks like we don't have an administrator set up yet. Either this is
your first time using Bugzilla, or your administrator's privileges
might have accidentally been deleted.
Enter the e-mail address of the administrator:

现在按照提示并完成您的设置(在这里使用您的值作为答案):

Enter the e-mail address of the administrator: youremail@yourdomain.tld
Enter the real name of the administrator: Der PCFreak
Enter a password for the administrator account: adminpassword
Please retype the password to verify: adminpassword
youremail@yourdomain.tld is now set up as an administrator.

当一切顺利的时候,你应该会看到:

1
2
3
4
5
6
Creating initial dummy product 'TestProduct'...
Now that you have installed Bugzilla, you should visit the 'Parameters'
page (linked in the footer of the Administrator account) to ensure it
is set up as you wish - this includes setting the 'urlbase' option to
the correct URL.
checksetup.pl complete.

在这一点上我们已经完成了。 执行以下行以注释掉Bugzilla安装脚本创建的 .htaccess 文件中的一行:

[root@localhost bugzilla]# sed -i ‘s/^Options -Indexes$/#Options -Indexes/g’ ./.htaccess

配置 Apache 来托管我们的 Bugzilla 安装

Apache 仍然不了解 Bugzilla 的任何内容。 所以让我们创建一个文件 /etc/httpd/conf.d/bugzilla.conf,并提供以下内容来将我们的 Bugzilla 网站介绍给 httpd.service。

1
2
3
4
5
6
7
8
9
10
#/etc/httpd/conf.d/bugzilla.conf
<VirtualHost *:80>
DocumentRoot /var/www/html/bugzilla/
</VirtualHost>
<Directory /var/www/html/bugzilla>
AddHandler cgi-script .cgi
Options +Indexes +ExecCGI
DirectoryIndex index.cgi
AllowOverride Limit FileInfo Indexes
</Directory>

创建文件后,我们重新启动 Apache,使更改生效:

[root@localhost bugzilla]# systemctl restart httpd.service

切换回普通用户

以 root 身份工作不再需要,如果您需要 root 权限,则可以使用 sudo。 所以执行以下命令来退出 root shell:

[root@localhost bugzilla]# exit
[installer@localhost ~]$

使用浏览器测试Bugzilla安装

使用浏览器打开 http://ip-of-your-server/ 将 ip-of-your-server 替换为服务器的IP地址)。 您现在应该看到 Bugzilla 页面,而不是默认的 Apache 测试页面。
您现在可以使用您提供给Bugzilla安装脚本的凭据进行登录。 在这个如何做到这一点是:

Email Address: youremail@yourdomain.tld
Password : adminpassword

Voila! 您现在已经在 CentOS 7 上安装了一个工作的 Bugzilla 5.0 安装。您现在可以继续在 Bugzilla Web 界面中设置 Bugzilla 的详细信息。