您的位置:首页 > 其它

Bugzilla2.20在Windows环境下的安装(三)

2005-10-19 19:09 260 查看
八、Perl Module安装:我对Perl不熟悉,我的理解是Perl Module是Perl需要做一个特定的事情时需要的相关组件。我们这里要让Perl支持bugzilla的运行,就需要安装必要的一些Module。安装Perl、配置bugzilla以及配置Apache服务器是交叉进行的,所以下边我将描述整个安装配置过程。

Bugzilla提供了一个checksetup.pl的文件,其实就是它的安装处理文件了,它可以检查必要的perl Module是否存在,然后还能创建数据库表,编译一些文件等。

在执行checksetup.pl之前,我们需要修改一些bugzilla的文件。因为我们是在windows环境下使用,bugzilla默认是用于Unix环境的,所以不得不对源文件做一些改动。

这是bugzilla自带的官方文档里的帮助,我们以此进行修改:打开安装目录内的Bugzilla/Bugmail.pm,即D:/tools/bugzilla/Bugzilla/BugMail.pm。将其中的
open(SENDMAIL, "|/usr/lib/sendmail $sendmailparam -t -i") ||
die "Can't open sendmail";
print SENDMAIL trim($msg) . "/n";
close SENDMAIL;
替换为:
use Net::SMTP;
my $smtp_server = 'smtp.mycompany.com';  # change this
# Use die on error, so that the mail will be in the 'unsent mails' and
# can be sent from the sanity check page.
my $smtp = Net::SMTP->new($smtp_server) ||
die 'Cannot connect to server /'$smtp_server/'';
$smtp->mail('bugzilla-daemon@mycompany.com');  # change this
$smtp->to($person);
$smtp->data();
$smtp->datasend($msg);
$smtp->dataend();
$smtp->quit;
现在要做一些改变。首先要把“smtp.mycompany.com”改为邮件服务器的地址,我们在本机安装了James做为邮件服务器,所以这里改为“127.0.0.1”。如果是使用外部邮件服务器,则修改为对应的地址。然后把bugzilla-daemon@mycompany.com修改为一个邮件发送者的邮箱,这个随便写一个即可,我们用James,所以这里我填了“bugzilla-daemon@127.0.0.1”。如果使用外部邮件服务器,很可能需要进行发送者身份验证,这里可以增加一行
$smtp->auth(’发送者账号’,’密码’);
James不需要身份验证,所以不用增加此项。 这里有一个很严重的问题是
$smtp->to($person);
这一行,不知道是bugzilla故意写错还是怎么样,后边使用checksetup.pl进行安装时,这一行编译不过去,报告的是$person没有进行声明。稍微有点编程知识的人在查看我们修改的这个位置所处的方法sub MessageToMTA ($) 内,并没有将$person做为参数传进来,也没有单独的声明,不出错才怪了。奇怪的在以前的bugzilla2.18中已经有这个问题了。 网上有这个问题的很多解决办法,通常是修改这个sub MessageToMTA ($)方法,在参数中增加一个值,将person做为参数传进来。同时在将参数值赋给$person。即将

sub MessageToMTA ($){

修改为

sub MessageToMTA ($$){

增加了一个$符号。接着把该方法开始位置的

my ($msg) = (@_);

修改为

my ($msg,$person) = (@_);

增加了对$person的参数赋值。



但是这样修改后,方法增加了一个参数。还需要对整个bugzilla的目录进行全面搜索,寻找使用到这个MessageToMTA的地方,然后修改为需要两个参数的形式。但是我发现很难确定应该如何设置需要传入的第二个参数。在我做了对应的修改后,并不能成功的发送邮件,而且都没有连接邮件服务器,所以决定不使用这种方式。



我的做法是在“$smtp->to($person);”这一行前加上#号将其注释掉,而且可以成功发送邮件,希望深入研究过的朋友给点建议。



现在修改BugMail.pm文件,将sub MessageToMTA ($)方法中的“$smtp->to($person);”用#号注释掉。

完成以上修改后保存。

现在在命令行模式进入bugzilla的安装目录,执行一下命令开始安装:
perl checksetup.pl
如果一切正常,将出现如下的提示信息:
D:/tools/bugzilla>perl checksetup.pl

Checking perl modules ...Checking for AppConfig (v1.52) not foundChecking for CGI (v2.93) ok: found v3.10Checking for Data::Dumper (any) ok: found v2.121_04Checking for Date::Format (v2.21) not foundChecking for DBI (v1.38) not foundChecking for File::Spec (v0.84) ok: found v3.05Checking for File::Temp (any) ok: found v0.16Checking for Template (v2.08) not foundChecking for Text::Wrap (v2001.0131) ok: found v2001.09293Checking for Mail::Mailer (v1.65) not foundChecking for Storable (any) ok: found v2.13

The following Perl modules are optional:Checking for GD (v1.20) not foundChecking for Chart::Base (v1.0) not foundChecking for XML::Parser (any) ok: found v2.34Checking for GD::Graph (any) not foundChecking for GD::Text::Align (any) not foundChecking for PatchReader (v0.9.4) not found

All the required modules are available at: http://landfill.bugzilla.org/ppm/You can add the repository with the following command: ppm rep add bugzilla http://landfill.bugzilla.org/ppm/

If you you want to see graphical bug charts (plotting historical data overtime), you should install libgd and the following Perl modules:

GD: ppm install GDChart: ppm install Chart

If you you want to see graphical bug reports (bar, pie and line charts ofcurrent data), you should install libgd and the following Perl modules:

GD: ppm install GDGD::Graph: ppm install GDGraphGD::Text::Align: ppm install GDTextUtil

If you want to see pretty HTML views of patches, you should install thePatchReader module:PatchReader: ppm install PatchReader



Bugzilla requires some Perl modules which are either missing fromyour system, or the version on your system is too old.They can be installed by running (as Administrator) the following: ppm install MailTools Minimum version required: 1.65 ppm install AppConfig Minimum version required: 1.52 ppm install Template-Toolkit Minimum version required: 2.08 ppm install TimeDate Minimum version required: 2.21 ppm install DBI Minimum version required: 1.38
其中的checkfor用来检查bugzilla需要用到的perl module是否存在,如果存在的话会显示“ok found”以及版本号,不存在的会显示“not found”。 接着看后边的提示信息,说使用如下命令可以把一个资源库加入perl的下载路径,来下载这些不存在的perl module。
ppm rep add bugzilla http://landfill.bugzilla.org/ppm/
现在执行这行命令,将出现下边的提示:
D:/tools/bugzilla>ppm rep add bugzilla http://landfill.bugzilla.org/ppm/Repositories:[1] ActiveState PPM2 Repository[2] ActiveState Package Repository[3] bugzilla
再看一下前边执行cheksetup.pl文件时列出的提示,其中有很多“ppm install xxx”这样的语句,这些其实就是用来下载并安装缺少的perl module的命令。现在在命令行中依次执行这些“ppm install xxx”命令。主要有下边这几个:
ppm install GDppm install Chartppm install GDGraphppm install GDTextUtilppm install PatchReaderppm install MailToolsppm install AppConfigppm install Template-Toolkitppm install TimeDateppm install DBI
因为我们使用了mysql数据库,需要再安装一个module:
Ppm install DBD-mysql
每次执行安装命令需要的时间是由你的网络速度决定的,可能会花些时间,你也可以写一个批处理文件来自动执行这些命令。 执行过程中有些时候会询问是否安装,请选择yes,或者需要你指定一个安装目录等,随意指定一个目录即可,我的是d:/tools/perl/module。

如果正常执行了一个安装程序,将出现类似如下的提示信息:
D:/tools/bugzilla>ppm install GD====================Install 'GD' version 2.16 in ActivePerl 5.8.7.813.====================Installing D:/tools/Perl/site/lib/auto/GD/GD.bsInstalling D:/tools/Perl/site/lib/auto/GD/GD.dllInstalling D:/tools/Perl/site/lib/auto/GD/GD.expInstalling D:/tools/Perl/site/lib/auto/GD/GD.libInstalling D:/tools/Perl/html/site/lib/GD.htmlInstalling D:/tools/Perl/html/site/lib/GD/Polyline.htmlFiles found in blib/arch: installing files in blib/lib into architecture dependent library treeInstalling D:/tools/Perl/site/lib/GD.pmInstalling D:/tools/Perl/site/lib/qd.plInstalling D:/tools/Perl/site/lib/auto/GD/autosplit.ixInstalling D:/tools/Perl/site/lib/GD/Polyline.pmSuccessfully installed GD version 2.16 in ActivePerl 5.8.7.813.
现在来再次执行perl checksetup.pl命令,提示应该显示必要的模块都可以找到了。
D:/tools/bugzilla>perl checksetup.pl

Checking perl modules ...Checking for AppConfig (v1.52) ok: found v1.55Checking for CGI (v2.93) ok: found v3.10Checking for Data::Dumper (any) ok: found v2.121_04Checking for Date::Format (v2.21) ok: found v2.22Checking for DBI (v1.38) ok: found v1.48Checking for File::Spec (v0.84) ok: found v3.05Checking for File::Temp (any) ok: found v0.16Checking for Template (v2.08) ok: found v2.13Checking for Text::Wrap (v2001.0131) ok: found v2001.09293Checking for Mail::Mailer (v1.65) ok: found v1.67Checking for Storable (any) ok: found v2.13

The following Perl modules are optional:Checking for GD (v1.20) ok: found v2.16Checking for Chart::Base (v1.0) ok: found v2.3Checking for XML::Parser (any) ok: found v2.34Checking for GD::Graph (any) ok: found v1.43Checking for GD::Text::Align (any) ok: found v1.18Checking for PatchReader (v0.9.4) ok: found v0.9.5

All the required modules are available at: http://landfill.bugzilla.org/ppm/You can add the repository with the following command: ppm rep add bugzilla http://landfill.bugzilla.org/ppm/

Checking user setup ...

This version of Bugzilla contains some variables that you maywant to change and adapt to your local settings. Please edit thefile './localconfig' and rerun checksetup.pl

The following variables are new to localconfig since you last ranchecksetup.pl: index_html cvsbin interdiffbin diffpath create_htaccess webservergroup db_driver db_host db_pass db_sock db_check
同时要求我们对自动生成的localconfig文件进行配置,主要是数据库的。现在打开bugzilla安装目录中的localconfig文件,这个文件是在执行了checksetup.pl后生成的。 因为我们是在本机安装了MySQL数据库,并且存储空间和用户名都是“bugs”,所以localconfig文件中的
$db_driver = “mysql”;$db_host = ‘localhost’;$db_name = ‘bugs’;$db_user = ‘bugs’;
都不用修改,默认即可。需要修改的是
$db_pass = ‘’;
这是bugs存储空间的bugs用户的密码,前边配置数据库时,密码设置为“bugs”,所以这里修改为:
$db_pass = ‘bugs’;
保存该文件,然后再来执行checksetup.pl文件。如果一切正常,将会出现一些正常的提示信息,然后会询问SMTP服务器的主机名是什么,因为我们在本机使用James,所以这里就填127.0.0.1。 接着会出现一些建表的提示信息,最后要求输入系统的超级管理员的邮箱账号、管理员名字、两次密码。 这样就结束了bugzilla的安装配置了。

现在来看Apache的配置,主要是Apache的httpd.conf文件,位于安装目录Apache Group下的Apache2/conf内。我的是“D:/tools/Apache Group/Apache2/htdocs/httpd.conf”。

打开它,首先找到
DocumentRoot "D:/tools/Apache Group/Apache2/htdocs"
这一行,将地址修改为bugzilla的安装目录:
DocumentRoot "D:/tools/bugzilla"
然后找到
<Directory "D:/tools/Apache Group/Apache2/htdocs">
这一行,在它与紧接着的</Directory>之间是我们主要修改的地方。 首先把
<Directory "D:/tools/Apache Group/Apache2/htdocs">
修改为bugzilla的安装目录:
<Directory "D:/tools/bugzilla">
然后将
Options Indexes FollowSymLinks
这一行修改为:
Options Indexes FollowSymLinks ExecCGI
还有把
AllowOverride None
一行改为
AllowOverride ALL
接着在</Directory>之前加一行:
ScriptInterpreterSource Registry-Strict
这一行很重要,是让Apache从注册表中寻找我们安装好的Perl的路径,使用Perl来对bugzilla里的cgi进行解释。

最后在整个httpd.conf中寻找如下一行:
DirectoryIndex index.html index.html.var
将其修改为:
DirectoryIndex index.html index.html.var index.cgi
指明让Apache能够以index.cgi做为访问的默认页面。

再寻找如下一行:
#AddHandler cgi-script .cgi
将其前边的#号去掉:
AddHandler cgi-script .cgi
下边我列出修改前和修改后的重要部分的对比,中间去掉了注释信息:修改前:
DocumentRoot "D:/tools/Apache Group/Apache2/htdocs"<Directory "D:/tools/Apache Group/Apache2/htdocs"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all</Directory>DirectoryIndex index.html index.html.var
修改后:
DocumentRoot "D:/tools/bugzilla"<Directory "D:/tools/bugzilla"> Options Indexes FollowSymLinks ExecCGI AllowOverride ALL Order allow,deny Allow from all ScriptInterpreterSource Registry-Strict</Directory>DirectoryIndex index.html index.html.var index.cgi
修改完成后保存。



修改注册表: 我们已经在httpd.conf文件中配置了让Apache在注册表中寻找Perl的安装路径,但是我们还没有在注册表中添加这些内容。现在就来新建一个注册表导入文件来完成添加。 新建一个名为cgi.reg的文件,添加如下内容:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT/.cgi]

[HKEY_CLASSES_ROOT/.cgi/Shell]

[HKEY_CLASSES_ROOT/.cgi/Shell/ExecCGI]

[HKEY_CLASSES_ROOT/.cgi/Shell/ExecCGI/Command]@="d://tools//perl//bin//perl.exe -T"
注意,最后一行应该是正确的perl安装路径。

保存后执行该文件完成注册表的修改。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: