搭建Bugzilla之前的准备工作
搭建Bugzilla之前检查下列软件包是否安装:
- apache2
- mysql
- perl & perl modules
- postfix
检查及安装过程如下所示
安装apache2
#dpkg -l apache2
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-============================-===================-===================-=============================================================
un apache2 <none> <none> (no description available)
如上输出,“un“表示apache2未安装,可使用apt-get命令安装:
# apt-get install apache2
# apache2 -v
Server version: Apache/2.4.7 (Ubuntu)
Server built: Jan 14 2016 17:45:23
使用同样的方法,检查mysql、perl和postfix是否安装。
安装mysql
# apt-get install mysql-server
安装过程中需要设置root用户密码:
再次确认密码:
# mysql -V
mysql Ver 14.14 Distrib 5.5.47, for debian-linux-gnu (x86_64) using readline 6.3
安装完毕后,设置创建bugs用户:
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 44
Server version: 5.5.47-0ubuntu0.14.04.1 (Ubuntu)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> GRANT SELECT, INSERT,
UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES,
CREATE TEMPORARY TABLES, DROP, REFERENCES ON bugs.* TO bugs@localhost IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;
mysql> quit
Bye
其中,passwd是bugs用户的登录密码。
安装perl
# apt-get install perl
# perl -v
This is perl 5, version 18, subversion 2(v5.18.2) built for x86_64-linux-gnu-thread-multi(with 44 registered patches, see perl -V for more detail)
Copyright 1987-2013, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
安装postfix
# apt-get install postfix
下载并安装Bugzilla
下载Bugzilla源码包
至2016年3月13日,Bugzilla的最新稳定版本更新至5.0.2。
可使用此链接下载Bugzilla源码包:bugzilla-5.0.2.tar.gz
安装Bugzilla所需Perl模块
解压源码包至/opt目录:
# tar xfz bugzilla-5.0.2.tar.gz -C /opt/
检查所需Perl模块是否安装:
# ./checksetup.pl
初次运行perl脚本将提示:
COMMANDS TO INSTALL OPTIONAL MODULES:
GD: /usr/bin/perl install-module.pl GD
Chart: /usr/bin/perl install-module.pl Chart::Lines
Template-GD: /usr/bin/perl install-module.pl Template::Plugin::GD::Image
GDTextUtil: /usr/bin/perl install-module.pl GD::Text
GDGraph: /usr/bin/perl install-module.pl GD::Graph
Apache-SizeLimit: /usr/bin/perl install-module.pl Apache2::SizeLimit
To attempt an automatic install of every required and optional module with one command, do:
/usr/bin/perl install-module.pl --all
Reading ./localconfig...
Checking for DBD-mysql (v4.001) ok: found v4.025
There was an error connecting to MySQL:
Access denied for user 'bugs'@'localhost' (using password: NO)
This might have several reasons:
* MySQL is not running.
* MySQL is running, but there is a problem either in the server configuration or the database access rights. Read the Bugzilla Guide in the doc directory. The section about database configuration should help.
* Your password for the 'bugs' user, specified in $db_pass, is incorrect, in './localconfig'.
* There is a subtle problem with Perl, DBI, or MySQL. Make sure all settings in './localconfig' are correct. If all else fails, set '$db_check' to 0.
按照提示修改localconfig文件:
$create_htaccess = 0;
$webservergroup = 'www-data';
$db_pass = 'passwd';
其中,passwd是创建bugs用户时设置的密码。
安装Perl模块:
# /usr/bin/perl install-module.pl --all
设置Bugzilla登录用户信息:
# ./checksetup.pl
...
Enter the e-mail address of the administrator: <Email Address>
Enter the real name of the administrator: <Your Name>
Enter a password for the administrator account: <Passwd>
Please retype the password to verify:<Passswd>
<Email Address> is now set up as an administrator.
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.
其中,Email Address是可用于登录Bugzilla的管理员账户,Passwd是登录密码。
配置apache2:
# vi /etc/apache2/conf-available/bugzilla.conf
<Directory "/var/www/html/bugzilla/">
AddHandler cgi-script .cgi
Options +Indexes +ExecCGI +FollowSymLinks
DirectoryIndex index.cgi
AllowOverride None
Order allow,deny
Allow from all
</Directory>
# cd /etc/apache2/conf-enabled
# ln -s ../conf-available/bugzilla.conf bugzilla.conf
# ln -s /opt/bugzilla-5.0.2/ /var/www/html/bugzilla
# /etc/init.d/apache2 restart
登录Bugzilla
在浏览器输入:http://ip/bugzilla,ip为本地网络地址。
安装过程中可能出现的问题解决
Q: GD模块安装出错
# /usr/bin/perl install-module.pl GD
...
**UNRECOVERABLE ERROR**
Could not find gdlib-config in the search path. Please install libgd 2.0.28 or higher.
...
A: 安装libgd2-xpm-dev
# sudo apt-get install libgd2-xpm-dev
Q: 无法在浏览器打开Bugzilla登录页面
#!/usr/bin/perl -T
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
use 5.10.1;
use strict;
use warnings;
use lib qw(. lib);
use Bugzilla;
use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::Update;
# Check whether or not the user is logged in
my $user = Bugzilla->login(LOGIN_OPTIONAL);
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
# And log out the user if requested. We do this first so that nothing
# else accidentally relies on the current login.
if ($cgi->param('logout')) {
Bugzilla->logout();
$user = Bugzilla->user;
$vars->{'message'} = "logged_out";
# Make sure that templates or other code doesn't get confused about this.
$cgi->delete('logout');
}
# Return the appropriate HTTP response headers.
print $cgi->header();
if ($user->in_group('admin')) {
# If 'urlbase' is not set, display the Welcome page.
unless (Bugzilla->params->{'urlbase'}) {
$template->process('welcome-admin.html.tmpl')
|| ThrowTemplateError($template->error());
exit;
}
# Inform the administrator about new releases, if any.
$vars->{'release'} = Bugzilla::Update::get_notifications();
}
if ($user->id) {
my $dbh = Bugzilla->dbh;
$vars->{assignee_count} =
$dbh->selectrow_array("SELECT COUNT(*) FROM bugs WHERE assigned_to = ? AND resolution = ''", undef, $user->id);
$vars->{reporter_count} =
$dbh->selectrow_array("SELECT COUNT(*) FROM bugs WHERE reporter = ? AND resolution = ''", undef, $user->id);
$vars->{requestee_count} =
$dbh->selectrow_array('SELECT COUNT(DISTINCT bug_id) FROM flags WHERE requestee_id = ?', undef, $user->id);
}
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("index.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
A: 启用cgi模块
# sudo a2enmod cgi
# sudo /etc/init.d/apache2 restart