CentOS 5.5部署Redmine 1.2.0与SVN集成Nginx指南
Redmine是一款基于Web的跨平台项目管理系统,由Ruby语言开发,基于ROR框架构建。作为项目管理领域的后起之秀,其灵感源自Basecamp的ROR版本,支持多种数据库后端。除具备DotProject等系统的基本功能外,还独有Wiki、新闻台、时间跟踪、Feed聚合及PDF导出等特色功能,并能无缝集成SVN、CVS、TD等版本控制及缺陷追踪系统。其配置灵活且强大,自定义属性与更新通知机制极具实用性。本文将详细演示如何部署Redmine结合SVN的项目管理体系(需严格遵循官方文档安装对应的Ruby包)
运行环境:CentOS 5.5,Redmine 1.2.0,Subversion 1.6.17
一、下载所需软件包
wget ftp://ftp.ruby-lang.org//pub/ruby/1.8/ruby-1.8.7.tar.gz
wget http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz
wget http://rubyforge.org/frs/download.php/74944/redmine-1.2.0.tar.gz
wget http://subversion.tigris.org/downloads/subversion-1.6.17.tar.gz
wget http://subversion.tigris.org/downloads/subversion-deps-1.6.17.tar.gz
二、配置LNMP基础环境
参考指南:《CentOS 5.5下安装mysql5.1.57+php5.2.17(FastCGI)+nginx1.0.1高性能Web服务器》
三、Redmine安装(对各软件包版本要求极为严格,必须对应相应版本,否则会出现不可预知的错误)
1、Ruby安装:
tar zxvf ruby-1.8.7.tar.gz
cd ruby-1.8.7
./configure --prefix=/usr/local/ruby
make && make install
cd ..
修改~/.bash_profile文件,将Ruby目录加入root用户的环境变量中 或者
echo "export PATH=$PATH:/usr/local/ruby/bin/" >> /etc/profile
2、Rubygems安装
安装rubygems时需注意,版本必须低于1.7.0,否则Redmine无法正常启动使用。笔者曾因参考某中文文档安装了1.7.0版本,导致Redmine无法工作,走了不少弯路,最终在官方文档中找到问题根源。以下是官网关于版本要求的描述: 复制代码 代码如下:Ruby 1.9 is not supported yet. You have to use Ruby 1.8.x as stated above. RubyGems 1.3.7 or higher is required with following limitations : Rails 2.3.5 will fail with RubyGems 1.5.0 or later, stick to previous versions of RubyGems ! Rails 2.3.11 will fail with RubyGems 1.7.0 or later, stick to previous versions of RubyGems ! Rake 0.8.7 is required (rake 0.9.x is not supported by Rails yet) Rack 1.1.x is required, 1.1.0 has a bug with quotes (#8416). Database migration would fail with other version. Mongrel 1.1.5 needs a patch attached to #7688 to work fine with Rails 2.3.11. In case of upgrade, another issue may appear for some time after migration (#7857). I18n 0.4.2 is required for Redmine >= 1.0.5
tar zxvf rubygems-1.6.2.tgz
cd rubygems-1.6.2
ruby setup.rb
cd ..
3、安装rails、rack、i18n、mysql及passenger
gem install rails -v=2.3.11
gem install rack -v=1.1.1
gem install i18n -v=0.4.2
gem install mysql --no-rdoc --no-ri -- --with-mysql-dir=/data/soft/mysql #我的mysql是编译安装在/data/soft/mysql目录下的
gem install passenger
gem install mongrel mongrel_cluster
四、安装配置Redmine
1、解压Redmine压缩包
tar zxvf redmine-1.2.0.tar.gz
mv redmine-1.2.0 /data/www/redmine
chown -R www. /data/www/redmine
2、建立数据库实例
/data/soft/mysql/bin/mysql -uroot -p
mysql> createdatabase redmine characterset utf8;
mysql> grantallon redmine.* to 'redmine'@'localhost' identified by 'redmine';
mysql> flush privileges;
3、修改Redmine MySQL数据库配置文件
cd /data/www/redmine/config
cp database.yml.example database.yml
vi database.yml
production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: redmine
encoding: utf8
注意:冒号后面必须保留一个空格...
4、创建运行数据库:
生成会话存储密钥:
cd /data/www/redmine
rake generate_session_store
随后开始创建数据库表结构,在Redmine根目录下执行:
RAILS_ENV=production rake db:migrate
读取默认配置数据,当遇到选择语言(Select language)提示时,选择zh:
RAILS_ENV=production rake redmine:load_default_data
5、配置mongrel_cluster
cd /data/www/redmine
mongrel_rails cluster::configure -e production -p 8000 -a 127.0.0.1 -N 3
6、启用mongrel_cluster
cd /data/www/redmine
mongrel_rails cluster::start
如果启动出现如下错误:
复制代码 代码如下:starting port 8000 !!! Path to pid file not valid: tmp/pids/mongrel.8000.pid mongrel::start reported an error. Use mongrel_rails mongrel::start -h to get help. starting port 8001 !!! Path to pid file not valid: tmp/pids/mongrel.8001.pid mongrel::start reported an error. Use mongrel_rails mongrel::start -h to get help. starting port 8002 !!! Path to pid file not valid: tmp/pids/mongrel.8002.pid mongrel::start reported an error. Use mongrel_rails mongrel::start -h to get help.
只需创建/data/www/redmine/tmp/pids目录即可解决
mkdir -p /data/www/redmine/tmp/pids
启动成功后的输出如下:
[root@CentOS5 redmine]# mongrel_rails cluster::start
starting port 8000
starting port 8001
starting port 8002
7、配置Nginx
复制代码 代码如下:vi /data/soft/nginx/conf/nginx.conf upstream mongrel { server 127.0.0.1:8000; server 127.0.0.1:8001; server 127.0.0.1:8002; } server { listen 80; server_name 192.168.8.32; root /data/www/redmine; index index.html index.htm; location / { proxy_pass http://mongrel; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
五、访问Redmine进行测试:
http://192.168.8.32

也可以直接使用Ruby内置的Webrick服务启动Redmine
/usr/local/ruby/bin/ruby /data/www/redmine/script/server webrick -e production &
启动成功后的日志如下:
[root@CentOS5 redmine]# /usr/local/ruby/bin/ruby /data/www/redmine/script/server webrick -e production &
[1] 3526
[root@CentOS5 redmine]# => Booting WEBrick
=> Rails 2.3.11 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-06-2409:30:47] INFO WEBrick 1.3.1
[2011-06-2409:30:47] INFO ruby 1.8.7 (2008-05-31) [i686-linux]
[2011-06-2409:30:47] INFO WEBrick::HTTPServer#start: pid=3526 port=3000
访问Redmine进行测试: http://192.168.8.32:3000

六、配置SVN服务器 七、在Redmine中配置SVN 进入Redmine目录下的Config文件夹,找到文件“configuration.yml.example”,将其复制并重命名为“configuration.yml”,然后修改其中的SVN相关配置
复制代码 代码如下:scm_subversion_command: svn
注意:此处需要在环境变量PATH中添加svn命令所在的目录路径 重启服务器后,配置SCM 新建项目test,配置版本库 SCM-->选择Subversion URL-->填写svn://192.168.8.32/test(根据实际SVN配置自行修改) 登录名-->test(根据实际SVN配置自行修改) 密码-->test(根据实际SVN配置自行修改) 保存设置即可
