TranslateProject/sources/tech/20151208 How to Install Bugzilla with Apache and SSL on FreeBSD 10.2.md

268 lines
8.3 KiB
Markdown
Raw Normal View History

2015-12-15 11:48:11 +08:00
如何在FreeBSD 10.2上配置Apache和SSL并安装Bugzilla
2015-12-08 15:16:50 +08:00
================================================================================
2015-12-16 16:20:34 +08:00
Bugzilla是一款bug跟踪系统和测试工具它基于web且开源由mozilla计划开发并由Mozilla公共许可证授权。它经常被一些高科技公司如mozilla、红帽公司和gnome使用。Bugzilla起初由Terry Weissman在1998年创立它用perl语言编写用MySQL作为后端数据库。它是一款旨在帮助管理软件开发的服务器软件它功能丰富、高优化度的数据库、卓越的安全性、高级的搜索工具、整合邮件功能等等。
2015-12-08 15:16:50 +08:00
2015-12-17 11:19:44 +08:00
在本教程中我们将给web服务器安装bugzilla 5.0的apache并为它启用SSL然后在freebsd 10.2上安装mysql 5.1来作为数据库系统。
2015-12-08 15:16:50 +08:00
2015-12-15 11:48:11 +08:00
#### 准备 ####
2015-12-08 15:16:50 +08:00
2015-12-16 16:20:34 +08:00
FreeBSD 10.2 - 64位
Root权限
2015-12-08 15:16:50 +08:00
2015-12-15 11:48:11 +08:00
### 第一步 - 更新系统 ###
2015-12-08 15:16:50 +08:00
2015-12-17 11:19:44 +08:00
用ssl登录freebsd服务器并更新库
2015-12-08 15:16:50 +08:00
sudo su
freebsd-update fetch
freebsd-update install
2015-12-15 11:48:11 +08:00
### 第二步 - 安装并配置Apache ###
2015-12-08 15:16:50 +08:00
2015-12-17 11:19:44 +08:00
在这一步我们将从freebsd库中用pkg命令安装apache然后在apache24目录下编辑"httpd.conf"文件启用SSL和CGI支持。
2015-12-08 15:16:50 +08:00
2015-12-17 11:19:44 +08:00
用pkg命令安装apache
2015-12-08 15:16:50 +08:00
pkg install apache24
2015-12-17 11:19:44 +08:00
进入apache目录并用nano编辑器编辑"httpd.conf"文件:
2015-12-08 15:16:50 +08:00
cd /usr/local/etc/apache24
nano -c httpd.conf
2015-12-17 11:19:44 +08:00
反注释掉下面列出的行:
2015-12-08 15:16:50 +08:00
2015-12-17 11:19:44 +08:00
#第70行
2015-12-08 15:16:50 +08:00
LoadModule authn_socache_module libexec/apache24/mod_authn_socache.so
2015-12-17 11:19:44 +08:00
#第89行
2015-12-08 15:16:50 +08:00
LoadModule socache_shmcb_module libexec/apache24/mod_socache_shmcb.so
2015-12-17 11:19:44 +08:00
#第117行
2015-12-08 15:16:50 +08:00
LoadModule expires_module libexec/apache24/mod_expires.so
2015-12-17 11:19:44 +08:00
#第141行启用SSL
2015-12-08 15:16:50 +08:00
LoadModule ssl_module libexec/apache24/mod_ssl.so
2015-12-17 11:19:44 +08:00
#第162行支持cgi
2015-12-08 15:16:50 +08:00
LoadModule cgi_module libexec/apache24/mod_cgi.so
2015-12-17 11:19:44 +08:00
#第174行启用mod_rewrite
2015-12-08 15:16:50 +08:00
LoadModule rewrite_module libexec/apache24/mod_rewrite.so
2015-12-17 11:19:44 +08:00
#第219行,服务器名配置
2015-12-08 15:16:50 +08:00
ServerName 127.0.0.1:80
2015-12-17 11:19:44 +08:00
保存并退出。
2015-12-08 15:16:50 +08:00
2015-12-17 11:19:44 +08:00
接着我们需要从freebsd库中安装mod perl并启用它
2015-12-08 15:16:50 +08:00
pkg install ap24-mod_perl2
2015-12-17 11:19:44 +08:00
启用mod_perl编辑"httpd.conf"文件并添加"Loadmodule"行:
2015-12-08 15:16:50 +08:00
nano -c httpd.conf
2015-12-17 11:19:44 +08:00
添加该行:
2015-12-08 15:16:50 +08:00
2015-12-17 11:19:44 +08:00
#第175行
2015-12-08 15:16:50 +08:00
LoadModule perl_module libexec/apache24/mod_perl.so
2015-12-17 11:19:44 +08:00
保存并退出。
2015-12-08 15:16:50 +08:00
2015-12-17 11:19:44 +08:00
在启用apache之前用sysrc命令添加以下行来在引导的时候启动
2015-12-08 15:16:50 +08:00
sysrc apache24_enable=yes
service apache24 start
2015-12-15 11:48:11 +08:00
### 第三步 - 安装并配置MySQL数据库 ###
2015-12-08 15:16:50 +08:00
2015-12-22 17:12:41 +08:00
我们要用mysql 5.1来作为后端数据库并且支持perl模块。用pkg命令安装mysql 5.1
2015-12-08 15:16:50 +08:00
pkg install p5-DBD-mysql51 mysql51-server mysql51-client
2015-12-22 17:12:41 +08:00
现在我们要在启动时添加mysql服务并启动然后为mysql配置root密码。
2015-12-08 15:16:50 +08:00
2015-12-22 17:12:41 +08:00
运行以下命令来完成所有操作:
2015-12-08 15:16:50 +08:00
sysrc mysql_enable=yes
service mysql-server start
mysqladmin -u root password aqwe123
2015-12-22 17:12:41 +08:00
注意:
2015-12-08 15:16:50 +08:00
2015-12-22 17:12:41 +08:00
这里mysql密码为aqwe123
2015-12-08 15:16:50 +08:00
![Configure MySQL Password](http://blog.linoxide.com/wp-content/uploads/2015/12/Configure-MySQL-Password.png)
2015-12-30 11:06:26 +08:00
以上步骤都完成之后我们用root登录mysql shell然后为bugzilla创建一个新的数据库和用户。
2015-12-08 15:16:50 +08:00
2015-12-30 11:06:26 +08:00
用以下命令登录mysql shell
2015-12-08 15:16:50 +08:00
mysql -u root -p
password: aqwe123
2015-12-30 11:06:26 +08:00
添加数据库:
2015-12-08 15:16:50 +08:00
create database bugzilladb;
create user bugzillauser@localhost identified by 'bugzillauser@';
grant all privileges on bugzilladb.* to bugzillauser@localhost identified by 'bugzillauser@';
flush privileges;
\q
![Creating Database for Bugzilla](http://blog.linoxide.com/wp-content/uploads/2015/12/Creating-Database-for-Bugzilla.png)
2015-12-30 11:06:26 +08:00
bugzilla的数据库创建好了名字为"bugzilladb",用户名和密码分别为"bugzillauser"和"bugzillauser@"。
2015-12-08 15:16:50 +08:00
2015-12-30 11:06:26 +08:00
### 第四步 - 生成新的SSL证书 ###
2015-12-08 15:16:50 +08:00
2015-12-30 11:06:26 +08:00
在bugzilla站点的"ssl"目录里生成新的自签名SSL证书。
2015-12-08 15:16:50 +08:00
2015-12-30 11:06:26 +08:00
前往apache24目录并在此创建新目录"ssl"
2015-12-08 15:16:50 +08:00
cd /usr/local/etc/apache24/
mkdir ssl; cd ssl
2015-12-30 11:06:26 +08:00
接着用openssl命令生成证书文件然后更改其权限
2015-12-08 15:16:50 +08:00
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /usr/local/etc/apache24/ssl/bugzilla.key -out /usr/local/etc/apache24/ssl/bugzilla.crt
chmod 600 *
2015-12-15 11:48:11 +08:00
### 第五步 - 配置虚拟主机 ###
2015-12-08 15:16:50 +08:00
We will install bugzilla on directory "/usr/local/www/bugzilla", so we must create new virtualhost configuration for it.
Go to the apache directory and create new directory called "vhost" for virtualhost file :
cd /usr/local/etc/apache24/
mkdir vhost; cd vhost
Now create new file "bugzilla.conf" for the virtualhost file :
nano -c bugzilla.conf
Paste configuration below :
<VirtualHost *:80>
ServerName mybugzilla.me
ServerAlias www.mybuzilla.me
DocumentRoot /usr/local/www/bugzilla
Redirect permanent / https://mybugzilla.me/
</VirtualHost>
Listen 443
<VirtualHost _default_:443>
ServerName mybugzilla.me
DocumentRoot /usr/local/www/bugzilla
ErrorLog "/var/log/mybugzilla.me-error_log"
CustomLog "/var/log/mybugzilla.me-access_log" common
SSLEngine On
SSLCertificateFile /usr/local/etc/apache24/ssl/bugzilla.crt
SSLCertificateKeyFile /usr/local/etc/apache24/ssl/bugzilla.key
<Directory "/usr/local/www/bugzilla">
AddHandler cgi-script .cgi
Options +ExecCGI
DirectoryIndex index.cgi index.html
AllowOverride Limit FileInfo Indexes Options
Require all granted
</Directory>
</VirtualHost>
2015-12-30 11:06:26 +08:00
保存并退出。
2015-12-08 15:16:50 +08:00
If all is done, create new directory for bugzilla installation and then enable the bugzilla virtualhost by adding the virtualhost configuration to httpd.conf file.
Run command below on "apache24" directory :
mkdir -p /usr/local/www/bugzilla
cd /usr/local/etc/apache24/
nano -c httpd.conf
In the end of the line, add configuration below :
Include etc/apache24/vhost/*.conf
Save and exit.
Now test the apache configuration with "apachectl" command and restart it :
apachectl configtest
service apache24 restart
2015-12-15 11:48:11 +08:00
### 第六步 - 安装Bugzilla ###
2015-12-08 15:16:50 +08:00
We can install bugzilla manually by downloading the source, or install it from freebsd repository. In this step we will install bugzilla from freebsd repository with pkg command :
pkg install bugzilla50
If it's done, go to the bugzilla installation directory and install all perl module that needed by bugzilla.
cd /usr/local/www/bugzilla
./install-module --all
Wait it until all is finished, it is take the time.
Next, generate the configuration file "localconfig" by executing "checksetup.pl" file on bugzilla installation directory.
./checksetup.pl
You will see the error message about the database configuration, so edit the file "localconfig" with nano editor :
nano -c localconfig
Now add the database that was created on step 3.
#Line 57
$db_name = 'bugzilladb';
#Line 60
$db_user = 'bugzillauser';
#Line 67
$db_pass = 'bugzillauser@';
Save and exit.
Then run "checksetup.pl" again :
./checksetup.pl
You will be prompt about mail and administrator account, fill all of it with your email, user and password.
![Admin Setup](http://blog.linoxide.com/wp-content/uploads/2015/12/Admin-Setup.png)
In the last, we need to change the owner of the installation directory to user "www", then restart apache with service command :
cd /usr/local/www/
chown -R www:www bugzilla
service apache24 restart
Now Bugzilla is installed, you can see it by visiting mybugzilla.me and you will be redirect to the https connection.
Bugzilla home page.
![Bugzilla Home](http://blog.linoxide.com/wp-content/uploads/2015/12/Bugzilla-Home.png)
Bugzilla admin panel.
![Bugzilla Admin Page](http://blog.linoxide.com/wp-content/uploads/2015/12/Bugzilla-Admin-Page.png)
2015-12-15 11:48:11 +08:00
### 结论 ###
2015-12-08 15:16:50 +08:00
Bugzilla is web based application help you to manage the software development. It is written in perl and use MySQL as the database system. Bugzilla used by mozilla, redhat, gnome etc for help their software development. Bugzilla has a lot of features and easy to configure and install.
--------------------------------------------------------------------------------
via: http://linoxide.com/tools/install-bugzilla-apache-ssl-freebsd-10-2/
作者:[Arul][a]
2015-12-15 11:48:11 +08:00
译者:[ZTinoZ](https://github.com/ZTinoZ)
2015-12-08 15:16:50 +08:00
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
2015-12-15 10:09:11 +08:00
[a]:http://linoxide.com/author/arulm/