專案

一般

個人檔案

動作

如何在 CentOS 上安裝 Redmine(詳細)

簡介

我花了不少時間尋找一個好的議題追蹤/專案管理解決方案。在廣泛考慮了開源和商業解決方案(價格範圍高達每月 200 美元,例如 Jira+Confluence 和 Zoho Projects)之後,我決定使用 Redmine,因為它提供了良好的議題追蹤和專案管理功能組合,尤其是狀態工作流程、子任務和任務相依性以及我們需要的所有其他功能。

然而,當我決定部署 Redmine 時,我遇到了許多困難,因為在我的工作場所,我們使用 PHP 並且不熟悉 Ruby on Rails,而對於任何不熟悉 Ruby on Rails 的人來說,設定它相當困難,這主要是由於各種版本相依性和不相容性,以及缺乏關於如何做到這一點的良好詳細文件。我設法使用 MySQL、Apache 和 Mongrel 在 Windows XP 上設定了 Redmine,但是當我嘗試在 Windows Server 2008 上安裝相同的設定時,我遇到了 RoR 和 MySQL 的各種問題,所以我決定在 CentOS 上設定,這也是我們用於生產網路託管的系統。

CentOS 是基於 Linux 的生產環境中最常選擇的 Linux 作業系統之一。關於設定 CentOS 的文件非常豐富,對於所有級別的內部 Linux 伺服器部署和管理能力的組織而言,它可以說是部署和運行生產 Linux 伺服器的最佳選擇。

Redmine 是最佳(就算不是「唯一最佳」)的開放原始碼問題追蹤與專案管理應用程式之一,但因為它是使用 Ruby on Rails 開發的,因此對於不熟悉 Ruby on Rails 環境的人來說,部署可能會相當複雜。

本操作說明提供在 CentOS 作業系統上使用下列元件啟動並執行 Redmine 所需的詳細步驟
  • Apache 網頁伺服器
  • MySQL 資料庫管理系統
  • Ruby on Rails
  • Mod Passenger Apache 模組

本操作說明提供安裝的詳細指示,並說明每個步驟的作用,以便熟悉和不熟悉 Ruby on Rails 環境的人都能輕鬆遵循。

假設

  • CentOS 已安裝並正常運作
  • Apache 已安裝並正常運作
  • MySQL 已安裝並正常運作
  • 您是以 root 身分登入
  • 後續步驟會依序完成,且不會出現錯誤

安裝說明

安裝 gem 與 passenger 依賴元件

yum -y install zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel

取得 Ruby

# Create the directory where you will store the Downloads
mkdir ~/Downloads # This can be any directory.

# Change to directory where you will store the download
cd ~/Downloads # This can be any directory.

# FTP to where you will download ruby from.
# When asked to login use user/password of anonymous/anonymous
ftp ftp.ruby-lang.org 
Name (ftp.ruby-lang.org:root): anonymous
Password: anonymous

ftp> cd /pub/ruby
ftp> get ruby-1.8.7-pXXX.tar.gz
ftp> quit

# You have now downloaded ruby and need to untar it
tar zxvf ruby-1.8.7-pXXX.tar.gz

# Compile ruby
cd ruby-1.8.7-pXXX
./configure
make
make install

# Verify ruby installation
ruby -v
which ruby

# Change back into your downloads directory
cd ..

取得 Gems 1.4.2(與 Gems 1.5 不相容)

wget http://production.cf.rubygems.org/rubygems/rubygems-1.4.2.tgz
tar zxvf rubygems-1.4.2.tgz
cd rubygems-1.4.2
ruby setup.rb
gem -v
which gem
cd ..

安裝 Passenger(需要 gcc)

gem install passenger
passenger-install-apache2-module

另一種方法是從下列位置安裝 Apache 的 mod_passenger RPM
http://passenger.stealthymonkeys.com/

RHEL/CentOS 5

rpm -Uvh http://passenger.stealthymonkeys.com/rhel/5/passenger-release.noarch.rpm
yum install mod_passenger

RHEL/CentOS 6

rpm --import http://passenger.stealthymonkeys.com/RPM-GPG-KEY-stealthymonkeys.asc
yum install http://passenger.stealthymonkeys.com/rhel/6/passenger-release.noarch.rpm
yum install mod_passenger

重新啟動 Apache

service httpd restart

下載 Redmine

下載頁面:http://rubyforge.org/frs/?group_id=1850

wget http://rubyforge.org/frs/download.php/75597/redmine-1.3.0.tar.gz  # GET LATEST VERSION ON RUBYFORGE
tar zxvf redmine-1.3.0.tar.gz

將資料夾複製到其 HTTP 文件根目錄資料夾

cp -av redmine-1.3.0/* /var/www/redmine

設定 Apache 以裝載文件

如需更多資訊,請參閱:設定 Apache 以執行 Redmine 的方法

安裝 Bundler

gem install bundler

新增 Bundler Boot 與預先初始化程式碼

如需更多資訊,請前往 Bundler 網站

建立 Gemfile 並在其中註冊這些 gem

vi /var/www/redmine/Gemfile
# file: /var/www/redmine/Gemfile
source "http://rubygems.org" 
gem "rake", "0.8.3" 
gem "rack", "1.1.0" 
gem "i18n", "0.4.2" 
gem "rubytree", "0.5.2", :require => "tree" 
gem "RedCloth", "~>4.2.3", :require => "redcloth" # for CodeRay
gem "mysql" 
gem "coderay", "~>0.9.7" 
bundle install

建立 Redmine MySQL 資料庫

yum install mysql-server
chkconfig mysqld on
service mysqld start
/usr/bin/mysql_secure_installation

針對 MySQL
啟動 mysql 用戶端 (mysql -u root -p) 並輸入下列指令

create database redmine character set utf8;
create user 'redmine'@'localhost' identified by 'my_password';
grant all privileges on redmine.* to 'redmine'@'localhost'; 

對於 5.0.2 之前的 MySQL 版本 - 請略過「建立使用者」步驟,改為

 grant all privileges on redmine.* to 'redmine'@'localhost' identified by 'my_password';

設定 /var/www/redmine/config/database.yml(重新命名 database.yml.example)

設定生產環境(選用)

取消註解 redmine/config/environment.rb 檔案中的下列行

ENV['RAILS_ENV'] ||= 'production'

產生工作階段存放區

RAILS_ENV=production bundle exec rake generate_session_store

遷移資料庫模型

RAILS_ENV=production bundle exec rake db:migrate

載入預設資料(選用)

RAILS_ENV=production bundle exec rake redmine:load_default_data

請依照指示操作。

重新命名 /var/www/redmine/public/ 中的 dispatch CGI 檔案

mv dispatch.cgi.example dispatch.cgi
mv dispatch.fcgi.example dispatch.fcgi
mv dispatch.rb.example dispatch.rb

編輯 .htaccess 檔案以進行 CGI 調度設定

mv htaccess.fcgi.example .htaccess

針對 Apache 使用者的讀取/寫入權限對檔案執行 Chown 與 Chmod

cd ..
chown -R apache:apache redmine-1.x
chmod -R 755 redmine-1.x

Redmine 現在應該已完整安裝並可完全使用

好好享受吧!

Nick Shel超過 12 年前 更新 · 3 個版本