h1. InstallationGuide

h1. CentOS 5.4环境下的安装部署

以下描述的是在CentOS5.4平台上redmine1.1.3的安装流程和数据迁移过程

h2. 安装流程的官方文档

http://www.redmine.org/projects/redmine/wiki/HowTo_install_Redmine_on_CentOS_5
http://www.redmine.org/projects/redmine/wiki/Redmine+Apache+Passenger_InstallOnRedHat

h2. 系统要求

Ruby 1.8.7 on Rails 2.3.11
MySQL 4 或更高版本(推荐)

h2. 安装步骤

# 数据库安装

yum install -y mysql mysql-server mysql-devel

# Ruby on Rails部署

#安装Ruby
mkdir /opt/source
cd /opt/source
wget http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7.tar.gz
tar zxvf ruby-1.8.7.tar.gz
cd ruby-1.8.7
./configure
make && make install
cd ext/zlib
ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
cd ../../
make && make install

#安装rubygems
cd /opt/source
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
gem install rails -v=2.3.11
gem install -v=0.4.2 i18n
gem install mysql
gem install rake -v=0.8.7
gem install rack -v=1.0.1
gem install passenger
passenger-install-apache2-module

# 启动MySQL数据库,创建redmine数据库

#启动Mysql数据库
/etc/init.d/mysqld start

#创建数据库与设置权限
mysql -u root -p
Enter password:

mysql> create database redmine character set utf8;
mysql> grant all on redmine.* to 'redmine'@'localhost' identified by 'redmine';
mysql> flush privileges;

# 配制redmine环境和数据库
我们可以把旧版数据库中的数据导入到新库中,同时把插件拷贝到新版的目录下

cd /opt/source
wget http://rubyforge.org/frs/download.php/74722/redmine-1.1.3.tar.gz
tar -zxf redmine-1.1.3.tar.gz
mv redmine-1.1.3 /opt/redmine
cd /opt/redmine/config
cp database.yml.example database.yml
vi database.yml

#database.yml配置项
production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: redmine
encoding: utf8

# 配置production环境

RAILS_ENV=production
rake config/initializers/session_store.rb

# 配置apache运行redmine,带有子路径/redmine
## 配置apache读写权限,重命名dispatch文件

cd /opt/redmine/
chown -R apache:apache files log tmp vendor
cd /opt/redmine/public
mv dispatch.cgi.example dispatch.cgi
mv dispatch.fcgi.example dispatch.fcgi
mv dispatch.rb.example dispatch.rb

## 编辑dispatch.cgi,加入以下内容

#注释掉 require "dispatcher"
#!/usr/local/bin/ruby
require /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/dispatcher.rb

## 编辑/opt/redmine/config/environment.rb,在底部加上

Redmine::Utils::relative_url_root = "/redmine"

## 编辑/etc/httpd/httpd.conf,加入以下内容

LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.7
PassengerRuby /usr/local/bin/ruby

ServerName redmine.funshion.com
DocumentRoot /home/www
RailsEnv production
RailsBaseURI /redmine
PassengerDefaultUser apache

## 创建文件链接

sudo ln -s /opt/redmine/public /home/www/redmine

## 修改/opt/redmine/config/environment.rb,加入

# The below line is already in the file
Rails::Initializer.run do |config|
# A bunch of stuff
config.action_controller.relative_url_root = '/redmine' # add this line here!
end

# 其他修改
#* ldap登录验证函数
修改/app/models/auth_source_ldap.rb文件中的authenticate函数

 def authenticate(login, password) return nil if login.blank? || password.blank? attrs = [] # get user's DN #ldap_con = initialize_ldap_con(self.account, self.account_password) #LDAP patch by Matthew if self.account.include? "$login" then logger.debug "LDAP-Auth with User login" ldap_con = initialize_ldap_con(self.account.sub("$login", login), password) else logger.debug "LDAP-Auth with Admin User" ldap_con = initialize_ldap_con(self.account, self.account_password) end login_filter = Net::LDAP::Filter.eq( self.attr_login, login ) object_filter = Net::LDAP::Filter.eq( "objectClass", "*" ) dn = String.new ldap_con.search( :base => self.base_dn, :filter => object_filter & login_filter, # only ask for the DN if on-the-fly registration is disabled :attributes=> (onthefly_register? ? ['dn', self.attr_firstname, self.attr_lastname, self.attr_mail] : ['dn'])) do |entry| dn = entry.dn attrs = {:firstname => AuthSourceLdap.get_attr(entry, self.attr_firstname), :lastname => AuthSourceLdap.get_attr(entry, self.attr_lastname), :mail => AuthSourceLdap.get_attr(entry, self.attr_mail), :auth_source_id => self.id } if onthefly_register? end return nil if dn.empty? logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug? # authenticate user ldap_con = initialize_ldap_con(dn, password) return nil unless ldap_con.bind # return user's attributes logger.debug "Authentication successful for '#{login}'" if logger && logger.debug? attrs rescue Net::LDAP::LdapError => text raise "LdapError: " + text end 

#* 修改首页指向R&D项目wiki,修改/config/routes.rb文件

#map.home '', :controller => 'welcome'
map.home '', :action => 'show', :project_id => 'research-develop', :controller => 'wiki'

#* 打开自定义样式开关,修改/lib/redmine/wiki_formatting/textile/formatter.rb文件

self.filter_styles=false

h1. Windows环境下的安装部署

以下描述的是在Windows平台上redmine0.9.3的安装流程和数据迁移过程

h2. 安装流程的官方文档

http://www.redmine.org/wiki/redmine/HowTo_Install_Redmine_in_a_sub-URI_on_Windows_with_Apache#Install-MySQL-51x

h2. 安装步骤

# 使用xampp套件安装集成环境
下载地址:http://sourceforge.net/projects/xampp/files/XAMPP%20Windows/
#* redmine0.9.x所需环境要求:
#** Windows XP/2003/2008 x86/x64
#** Apache HTTP Server 2.2.x
#** MySQL 4 或更高
#** PHP 5 启用LDAP插件
#** Ruby 1.8.7
#** Rails 2.3.5
#* xampp Release Name: 1.5.2 可用
Notes:
This version of XAMPP includes:
– Apache 2.2.0
– MySQL 5.0.20
– PHP 5.1.2 – PHP 4.4.2-pl1 – PEAR
– eAccelerator 0.9.4-rc1 (not stabil with PHP 5.1.2)
– PHP-Switch win32 1.0
– XAMPP Control Version 2.2 from www.nat32.com
– XAMPP Security 1.0
– SQLite 2.8.15
– OpenSSL 0.9.8a
– phpMyAdmin 2.8.0.3
– ADOdb 4.80
– Mercury Mail Transport System v4.01b
– FileZilla FTP Server 0.9.14a
– Webalizer 2.01-10
– Zend Optimizer 3.0.0
# 安装Ruby1.8.7
下载安装包rubyinstaller-1.8.7-p249-rc2.exe 在 http://rubyforge.org/frs/?group_id=167
# 安装RubyGems 1.3.5
命令行窗口输入

gem install rubygems-update -v 1.3.5
update_rubygems

#* 使用最新版1.3.6可能导致其他gems安装错误
# 安装附加gem
#* 安装mysql gem

gem install mysql

#** 安装成功后显示

Successfully installed mysql-2.8.1
No definition for ***

#* 安装Rake

gem install rake

#** 安装成功后显示

Successfully installed rake-0.8.7

#* 安装Rails

gem install rails -v=2.3.5

#** 安装成功后显示

Successfully installed activesupport-2.3.5
Successfully installed activerecord-2.3.5
Successfully installed actionpack-2.3.5
Successfully installed actionmailer-2.3.5
Successfully installed activeresource-2.3.5
Successfully installed rack-1.0.1
Successfully installed rails-2.3.5

#* 安装Mongrel

gem install mongrel

#** 安装成功后显示

Successfully installed gem_plugin-0.2.3
Successfully installed cgi_multipart_eof_fix-2.5.0
Successfully installed mongrel-1.1.5-x86-mswin32-60

#* 安装mongrel-service + win32-service gems
#** 下载 “mongrel_service-0.3.4-i386-mswin32.gem” 在 http://rubyforge.org/frs/?group_id=1306
#** 下载 “win32-service-0.5.2-mswin32.gem” 在 http://files.ruby.inoack.com/win32utils/
#** 编写批处理文件并运行,内容为:

call gem install \path\to\win32-service-0.5.2-mswin32.gem
call gem install \path\to\mongrel_service-0.3.4-i386-mswin32.gem

# 安装Redmine
## 下载安装文件于http://rubyforge.org/frs/?group_id=1850 ,并解压
## 在MySQL管理软件中执行以下sql:

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

##* 数据库用户权限可依情况自行设置
## 拷贝redmine\config\database.yml.example文件至redmine\config\database.yml
## 编辑database.yml
例如

production:
adapter: mysql
database: redmine
host: localhost
username: redmineUser
password: myPassword
encoding: utf8

## 命令行窗口,进入redmine目录下,执行

set RAILS_ENV=production
rake config/initializers/session_store.rb
rake db:migrate
rake redmine:load_default_data

##* 默认设置选择zh
## 假定redmine访问地址为http://localhost/redmine
编辑redmine\config\environment.rb文件
在底部添加如下内容:

Redmine::Utils::relative_url_root = "/redmine"

# 安装mongrel的windows服务
## 创建服务
命令行窗口输入:

mongrel_rails service::install -N mongrel_redmine -D "Mongrel serving Redmine" -p 3001 -e production -c \path\to\redmine

##* -N 指明服务名称
##* -D 指明服务显示名称
##* -p 指明mongrel监听端口
##* -e 指明启动模式
##* -c 指明应用所在目录
## 启动服务

net start mongrel_redmine

##* 如有必要可设置以上服务为自启动
# 配置Apache作为的代理
## 编辑apache\conf\httpd.conf文件
在底部添加如下内容:

Include conf/httpd-proxy-mongrel.conf

## 创建apache\conf\httpd-proxy-mongrel.conf文件
内容为

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

ProxyPass /redmine balancer://redmine_cluster
ProxyPassReverse /redmine balancer://redmine_cluster

BalancerMember http://127.0.0.1:3000

# 重启Apache服务,安装完成

h2. 如果mongrel无法正常使用,可用以下步骤代替上述第6步

为Ruby内置网页服务Webrick安装Windows服务
# 下载Windows NT Resource Kit并安装
在http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en 下载
# 使用resource kit命令行添加redmine服务
命令行输入

[resource kit install path]\INSTSRV.EXE Redmine [resource kit install path]\SRVANY.EXE

例如:

"C:\Program Files\Windows Resource Kits\Tools\INSTSRV.EXE" Redmine "C:\Program Files\Windows Resource
Kits\Tools\SRVANY.EXE"

# 使用注册表编辑器设置redmine服务
路径HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Redmine
#* 右键redmine,新建项”Parameters”
#* 右键Parameters,新建两个字符串值”Application”,”AppParameters”
#* Application的值:例如D:\Ruby\bin\ruby.exe
#* AppParameters的值,例如D:\redmine\script\server -e production
# 运行services.msc或服务管理工具将redmine服务设置为自启动

h2. 配置LDAP身份验证

# patch \app\models\auth_source_ldap.rb authenticate 方法

 def authenticate(login, password) return nil if login.blank? || password.blank? attrs = [] # get user's DN #ldap_con = initialize_ldap_con(self.account, self.account_password) #LDAP patch by Matthew if self.account.include? "$login" then logger.debug "LDAP-Auth with User login" ldap_con = initialize_ldap_con(self.account.sub("$login", login), password) else logger.debug "LDAP-Auth with Admin User" ldap_con = initialize_ldap_con(self.account, self.account_password) end login_filter = Net::LDAP::Filter.eq( self.attr_login, login ) object_filter = Net::LDAP::Filter.eq( "objectClass", "*" ) dn = String.new ldap_con.search( :base => self.base_dn, :filter => object_filter & login_filter, # only ask for the DN if on-the-fly registration is disabled :attributes=> (onthefly_register? ? ['dn', self.attr_firstname, self.attr_lastname, self.attr_mail] : ['dn'])) do |entry| dn = entry.dn attrs = {:firstname => AuthSourceLdap.get_attr(entry, self.attr_firstname), :lastname => AuthSourceLdap.get_attr(entry, self.attr_lastname), :mail => AuthSourceLdap.get_attr(entry, self.attr_mail), :auth_source_id => self.id } if onthefly_register? end return nil if dn.empty? logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug? # authenticate user ldap_con = initialize_ldap_con(dn, password) return nil unless ldap_con.bind # return user's attributes logger.debug "Authentication successful for '#{login}'" if logger && logger.debug? attrs rescue Net::LDAP::LdapError => text raise "LdapError: " + text end 

# 在Administration->settings->Authentication/LDAP authentication中创建一个LDAP认证
Name: Funshion
Host: main.funshion.com
Port: 389
Account: $login@funshion.com
Password:
Base DN: cn=users;dc=FUNSHION;dc=com
On-the-fly user creation: checked
Login: mailNickname
Firstname: givenName
Lastname: sn
Email: mail

h2. 数据迁移

h3. 数据库迁移(SQLite -> MySQL)

* 建议使用phpmyadmin进行导入

# 使用Firefox组件SQLite Manager导出每个表的数据为sql文件(除sqlite_sequence表)
# 修改插入语句,删除表名两侧的双引号,将所有转义符’\’替换为’\\’保存
# 由于redmine SQLite数据库中的Boolean字段在MySQL数据库中被替换为tinyint,所以要把所有的’t’和’f’替换为’1’和’0′
# 此时的sql文件即可供数据库导入。

h3. 附件迁移

# 将原站点files目录中的文件拷贝至新站点的相同目录即可



分享到: 更多

这篇日志的 QR 二维码为:

四月 17th, 2012

Posted In: 网络技术

发表评论

电子邮件地址不会被公开。 必填项已用*标注

无觅相关文章插件,快速提升流量