在 FreeBSD 10.2 上如何通过配置 Apache 和 SSL 安装 Bugzilla

Bugzilla 是一款开源的 Web 应用,用于 bug 跟踪系统和测试工具,由 mozilla 开发,并采用 Mozilla 公共许可证授权(MPL)。它经常被一些高科技公司如 mozilla、红帽公司和 gnome 使用。Bugzilla 起初由 Terry Weissman开发于1998年,它用 perl 语言编写,用 MySQL 作为后端数据库。它是一款旨在帮助管理软件开发的服务器软件,它有丰富的功能、高度优化的数据库、卓越的安全性、高级的搜索工具、集成了邮件功能等等。

在本教程中,我们将安装 bugzilla 5.0 ,采用 apache 作为 Web 服务器,并为它启用 SSL,然后在 freebsd 10.2 上安装 mysql 5.1 来作为数据库系统。

准备

  • FreeBSD 10.2 - 64位
  • Root 权限

 

第一步 - 更新系统

用 ssh 登录 freebsd 服务器,并更新软件库:

  1. <span class="kwd">sudo</span><span class="kwd">su</span>
  2. <span class="pln">freebsd</span><span class="pun">-</span><span class="pln">update fetch</span>
  3. <span class="pln">freebsd</span><span class="pun">-</span><span class="pln">update install</span>

 

第二步 - 安装并配置 Apache

在这一步我们将使用 pkg 命令从 freebsd 软件库中安装 apache,然后在 apache24 目录下编辑 "httpd.conf" 文件,来配置 apache 以启用 SSL 和 CGI 支持。

用 pkg 命令安装 apache:

  1. <span class="pln">pkg install apache24</span>

进入 apache 目录并用 nano 编辑器编辑"httpd.conf"文件:

  1. <span class="kwd">cd</span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">apache24</span>
  2. <span class="kwd">nano</span><span class="pun">-</span><span class="pln">c httpd</span><span class="pun">.</span><span class="pln">conf</span>

取消下面列出行的注释:

  1. <span class="com">#第</span><span class="lit">70</span><span class="pun">行</span>
  2. <span class="typ">LoadModule</span><span class="pln"> authn_socache_module libexec</span><span class="pun">/</span><span class="pln">apache24</span><span class="pun">/</span><span class="pln">mod_authn_socache</span><span class="pun">.</span><span class="pln">so</span>
  3. <span class="com">#第</span><span class="lit">89</span><span class="pun">行</span>
  4. <span class="typ">LoadModule</span><span class="pln"> socache_shmcb_module libexec</span><span class="pun">/</span><span class="pln">apache24</span><span class="pun">/</span><span class="pln">mod_socache_shmcb</span><span class="pun">.</span><span class="pln">so</span>
  5. <span class="com">#第</span><span class="lit">117</span><span class="pun">行</span>
  6. <span class="typ">LoadModule</span><span class="pln"> expires_module libexec</span><span class="pun">/</span><span class="pln">apache24</span><span class="pun">/</span><span class="pln">mod_expires</span><span class="pun">.</span><span class="pln">so</span>
  7. <span class="com">#第</span><span class="lit">141</span><span class="pun">行,启用</span><span class="pln">SSL</span>
  8. <span class="typ">LoadModule</span><span class="pln"> ssl_module libexec</span><span class="pun">/</span><span class="pln">apache24</span><span class="pun">/</span><span class="pln">mod_ssl</span><span class="pun">.</span><span class="pln">so</span>
  9. <span class="com">#第</span><span class="lit">162</span><span class="pun">行,支持</span><span class="pln">cgi</span>
  10. <span class="typ">LoadModule</span><span class="pln"> cgi_module libexec</span><span class="pun">/</span><span class="pln">apache24</span><span class="pun">/</span><span class="pln">mod_cgi</span><span class="pun">.</span><span class="pln">so</span>
  11. <span class="com">#第</span><span class="lit">174</span><span class="pun">行,启用</span><span class="pln">mod_rewrite</span>
  12. <span class="typ">LoadModule</span><span class="pln"> rewrite_module libexec</span><span class="pun">/</span><span class="pln">apache24</span><span class="pun">/</span><span class="pln">mod_rewrite</span><span class="pun">.</span><span class="pln">so</span>
  13. <span class="com">#第</span><span class="lit">219</span><span class="pun">行,服务器名配置</span>
  14. <span class="typ">ServerName</span><span class="lit">127.0</span><span class="pun">.</span><span class="lit">0.1</span><span class="pun">:</span><span class="lit">80</span>

保存并退出。

接着,我们需要从 freebsd 库中安装 mod perl,并启用它:

  1. <span class="pln">pkg install ap24</span><span class="pun">-</span><span class="pln">mod_perl2</span>

启用 mod_perl,编辑"httpd.conf"文件并添加"Loadmodule"行:

  1. <span class="kwd">nano</span><span class="pun">-</span><span class="pln">c httpd</span><span class="pun">.</span><span class="pln">conf</span>

添加该行:

  1. <span class="com">#第</span><span class="lit">175</span><span class="pun">行</span>
  2. <span class="typ">LoadModule</span><span class="pln"> perl_module libexec</span><span class="pun">/</span><span class="pln">apache24</span><span class="pun">/</span><span class="pln">mod_perl</span><span class="pun">.</span><span class="pln">so</span>

保存并退出。

在启用 apache 之前,用 sysrc 命令添加以下行作为开机启动项:

  1. <span class="pln">sysrc apache24_enable</span><span class="pun">=</span><span class="kwd">yes</span>
  2. <span class="pln">service apache24 start</span>

 

第三步 - 安装并配置 MySQL 数据库

我们要用 mysql 5.1 来作为后端数据库并且支持 perl 模块。用 pkg 命令安装 mysql 5.1:

  1. <span class="pln">pkg install p5</span><span class="pun">-</span><span class="pln">DBD</span><span class="pun">-</span><span class="pln">mysql51 mysql51</span><span class="pun">-</span><span class="pln">server mysql51</span><span class="pun">-</span><span class="pln">client</span>

现在我们要将 mysql 服务设置为开机启动,然后为 mysql 配置 root 密码。

运行以下命令来完成上述所有操作:

  1. <span class="pln">sysrc mysql_enable</span><span class="pun">=</span><span class="kwd">yes</span>
  2. <span class="pln">service mysql</span><span class="pun">-</span><span class="pln">server start</span>
  3. <span class="pln">mysqladmin </span><span class="pun">-</span><span class="pln">u root password aqwe123</span>

注意:

这里 mysql 密码为:aqwe123

在 FreeBSD 10.2 上如何通过配置 Apache 和 SSL 安装 Bugzilla

Configure MySQL Password

以上步骤都完成之后,我们用 root 登录 mysql shell,然后为 bugzilla 安装创建一个新的数据库和用户。

用以下命令登录 mysql shell:

  1. <span class="pln">mysql </span><span class="pun">-</span><span class="pln">u root </span><span class="pun">-</span><span class="pln">p</span>
  2. <span class="pln">password</span><span class="pun">:</span><span class="pln"> aqwe123</span>

添加数据库:

  1. <span class="pln">create database bugzilladb</span><span class="pun">;</span>
  2. <span class="pln">create user bugzillauser@localhost identified by </span><span class="str">'bugzillauser@'</span><span class="pun">;</span>
  3. <span class="pln">grant all privileges on bugzilladb</span><span class="pun">.*</span><span class="pln"> to bugzillauser@localhost identified by </span><span class="str">'bugzillauser@'</span><span class="pun">;</span>
  4. <span class="pln">flush privileges</span><span class="pun">;</span>
  5. <span class="pln">\q</span>

在 FreeBSD 10.2 上如何通过配置 Apache 和 SSL 安装 Bugzilla

Creating Database for Bugzilla

bugzilla 的数据库创建好了,名字为"bugzilladb",用户名和密码分别为"bugzillauser"和"bugzillauser@"。

 

第四步 - 生成新的 SSL 证书

在 bugzilla 站点的 "ssl" 目录里生成新的自签名 SSL 证书。

前往 apache24 目录并在此创建新目录 "ssl":

  1. <span class="kwd">cd</span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">apache24</span><span class="pun">/</span>
  2. <span class="kwd">mkdir</span><span class="pln"> ssl</span><span class="pun">;</span><span class="kwd">cd</span><span class="pln"> ssl</span>

接着,用 openssl 命令生成证书文件,然后更改其权限:

  1. <span class="kwd">sudo</span><span class="pln"> openssl req </span><span class="pun">-</span><span class="pln">x509 </span><span class="pun">-</span><span class="pln">nodes </span><span class="pun">-</span><span class="pln">days </span><span class="lit">365</span><span class="pun">-</span><span class="pln">newkey rsa</span><span class="pun">:</span><span class="lit">2048</span><span class="pun">-</span><span class="pln">keyout </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">apache24</span><span class="pun">/</span><span class="pln">ssl</span><span class="pun">/</span><span class="pln">bugzilla</span><span class="pun">.</span><span class="pln">key </span><span class="pun">-</span><span class="pln">out </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">apache24</span><span class="pun">/</span><span class="pln">ssl</span><span class="pun">/</span><span class="pln">bugzilla</span><span class="pun">.</span><span class="pln">crt</span>
  2. <span class="kwd">chmod</span><span class="lit">600</span><span class="pun">*</span>

 

第五步 - 配置虚拟主机

我们将在 "/usr/local/www/bugzilla" 目录里安装 bugzilla,所以我们必须为它创建新的虚拟主机配置。

前往 apache 目录并为虚拟主机文件创建名为 "vhost" 的新目录:

  1. <span class="kwd">cd</span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">apache24</span><span class="pun">/</span>
  2. <span class="kwd">mkdir</span><span class="pln"> vhost</span><span class="pun">;</span><span class="kwd">cd</span><span class="pln"> vhost</span>

现在为虚拟主机文件创建新文件 "bugzilla.conf":

  1. <span class="kwd">nano</span><span class="pun">-</span><span class="pln">c bugzilla</span><span class="pun">.</span><span class="pln">conf</span>

将以下配置粘贴进去:

  1. <span class="tag"><VirtualHost</span><span class="pln"> *:80</span><span class="tag">></span>
  2. <span class="pln">ServerName mybugzilla.me</span>
  3. <span class="pln">ServerAlias www.mybuzilla.me</span>
  4. <span class="pln">DocumentRoot /usr/local/www/bugzilla</span>
  5. <span class="pln">Redirect permanent / https://mybugzilla.me/</span>
  6. <span class="tag"></VirtualHost></span>
  7. <span class="pln">Listen 443</span>
  8. <span class="tag"><VirtualHost</span><span class="pln"> _</span><span class="atn">default_:443</span><span class="tag">></span>
  9. <span class="pln">ServerName mybugzilla.me</span>
  10. <span class="pln">DocumentRoot /usr/local/www/bugzilla</span>
  11. <span class="pln">ErrorLog "/var/log/mybugzilla.me-error_log"</span>
  12. <span class="pln">CustomLog "/var/log/mybugzilla.me-access_log" common</span>
  13. <span class="pln">SSLEngine On</span>
  14. <span class="pln">SSLCertificateFile /usr/local/etc/apache24/ssl/bugzilla.crt</span>
  15. <span class="pln">SSLCertificateKeyFile /usr/local/etc/apache24/ssl/bugzilla.key</span>
  16. <span class="tag"><Directory</span><span class="atv">"/usr/local/www/bugzilla"</span><span class="tag">></span>
  17. <span class="pln">AddHandler cgi-script .cgi</span>
  18. <span class="pln">Options +ExecCGI</span>
  19. <span class="pln">DirectoryIndex index.cgi index.html</span>
  20. <span class="pln">AllowOverride Limit FileInfo Indexes Options</span>
  21. <span class="pln">Require all granted</span>
  22. <span class="tag"></Directory></span>
  23. <span class="tag"></VirtualHost></span>

保存并退出。

上述都完成之后,为 bugzilla 安装创建新目录,并在 httpd.conf 文件添加虚拟主机配置来启用 bugzilla虚拟主机。

在 "apache24" 目录下运行以下命令:

  1. <span class="kwd">mkdir</span><span class="pun">-</span><span class="pln">p </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">bugzilla</span>
  2. <span class="kwd">cd</span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">apache24</span><span class="pun">/</span>
  3. <span class="kwd">nano</span><span class="pun">-</span><span class="pln">c httpd</span><span class="pun">.</span><span class="pln">conf</span>

文末,添加以下配置:

  1. <span class="typ">Include</span><span class="pln"> etc</span><span class="pun">/</span><span class="pln">apache24</span><span class="pun">/</span><span class="pln">vhost</span><span class="com">/*.conf</span>

保存并退出。

现在用 "apachectl" 命令测试一下 apache 的配置并重启它:

  1. <span class="pln">apachectl configtest</span>
  2. <span class="pln">service apache24 restart</span>

 

第六步 - 安装 Bugzilla

我们可以通过下载源来手动安装 bugzilla 了,或从 freebsd 库中安装也可以。在这一步中我们将用 pkg 命令从 freebsd 库中安装 bugzilla:

  1. <span class="pln">pkg install bugzilla50</span>

以上步骤都完成之后,前往 bugzilla 安装目录并安装所有 bugzilla 需要的 perl 模块。

  1. <span class="kwd">cd</span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">bugzilla</span>
  2. <span class="pun">./</span><span class="pln">install</span><span class="pun">-</span><span class="kwd">module</span><span class="pun">--</span><span class="pln">all</span>

要等到所有都完成,这需要点时间。

下一步,在 bugzilla 的安装目录中执行 "checksetup.pl" 文件来生成配置文件 "localconfig"。

  1. <span class="pun">./</span><span class="pln">checksetup</span><span class="pun">.</span><span class="pln">pl</span>

你会看到一条关于数据库配置错误的消息,你得用 nano 编辑器编辑一下 "localconfig" 文件:

  1. <span class="kwd">nano</span><span class="pun">-</span><span class="pln">c localconfig</span>

现在添加第三步创建的数据库。

  1. <span class="com">#第</span><span class="lit">57</span><span class="pun">行</span>
  2. <span class="pln">$db_name </span><span class="pun">=</span><span class="str">'bugzilladb'</span><span class="pun">;</span>
  3. <span class="com">#第</span><span class="lit">60</span><span class="pun">行</span>
  4. <span class="pln">$db_user </span><span class="pun">=</span><span class="str">'bugzillauser'</span><span class="pun">;</span>
  5. <span class="com">#第</span><span class="lit">67</span><span class="pun">行</span>
  6. <span class="pln">$db_pass </span><span class="pun">=</span><span class="str">'bugzillauser@'</span><span class="pun">;</span>

保存并退出。

然后再次运行 "checksetup.pl":

  1. <span class="pun">./</span><span class="pln">checksetup</span><span class="pun">.</span><span class="pln">pl</span>

你会收到输入邮箱名和管理员账号的提示,你只要输入你的邮箱、用户名和密码就行了。

在 FreeBSD 10.2 上如何通过配置 Apache 和 SSL 安装 Bugzilla

Admin Setup

最后,我们需要把安装目录的属主改成 "www",然后用服务命令重启 apache:

  1. <span class="kwd">cd</span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span>
  2. <span class="kwd">chown</span><span class="pun">-</span><span class="pln">R www</span><span class="pun">:</span><span class="pln">www bugzilla</span>
  3. <span class="pln">service apache24 restart</span>

现在 Bugzilla 已经安装好了,你可以通过访问 mybugzilla.me 来查看,并且将会重定向到 https 连接。

Bugzilla 首页:

在 FreeBSD 10.2 上如何通过配置 Apache 和 SSL 安装 Bugzilla

Bugzilla Home

Bugzilla admin 面板:

在 FreeBSD 10.2 上如何通过配置 Apache 和 SSL 安装 Bugzilla

Bugzilla Admin Page

 

结论

Bugzilla 是一个基于 web 的应用,并能帮助你管理软件开发,它用 perl 开发并以 MySQL 作为数据库系统。Bugzilla 帮助 mozilla、RedHat、gnome 等公司完成软件开发工作。Bugzilla 有很多功能并易于配置和安装。

Bugzilla 的详细介绍:请点这里
Bugzilla 的下载地址:请点这里


via: http://linoxide.com/tools/install-bugzilla-apache-ssl-freebsd-10-2/

作者:Arul 译者:ZTinoZ 校对:Caroline

本文由 LCTT 原创编译,Linux中国 荣誉推出

相关推荐