Ubuntu 10.04下安装Redmine

Category : 工作学习 / Tags : , , / Date : 2011.07.06 / /

  Redmine是一个灵活的项目管理与缺陷跟踪工具,它是基于Ruby on Rails框架建立的Web的应用程序。Redmine是项目管理系统的后起之秀,页面符合Web 2.0特性, 同时又简单易用, 给项目管理和进度度量带来极大的好处。Redmine支持多种数据库,除了和DotProject的功能大致相当外,还有不少自己独特的功能,例如提供wiki、新闻台、时间跟踪、feed聚合、导出pdf等等,还可以集成其他版本管理系统和BUG跟踪系统,例如SVN、CVS、TD等等。配置功能强大而且方便,自定义属性和更新通知也很实用。

  一、安装基础运行环境

  A、安装Ruby

apt-get install ruby
apt-get install ruby1.8-dev

  B、安装rubygem

apt-get install rubygems

  C、通过rubygems安装rails和rack

gem install rails -v=2.3.11
gem install rack -v=1.1.1

  D、安装其它依赖环境

gem install -v=0.4.2 i18n
gem install mysql
apt-get install libopenssl-ruby1.8
apt-get install libmysqlclient-dev

  二、安装Redmine

  A、获取并解压安装包

wget http://rubyforge.org/frs/download.php/74944/redmine-1.2.0.tar.gz
tar xvzf redmine-1.2.0.tar.gz
mv redmine-1.2.0/ redmine

  B、建立数据库

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

  注:我开始在这里用于连接数据库的密码为全数字(6个0)时,redmine一直连不上数据库,更改为字母或为空都可以连接,不知道这个是不是1.2版本程序的BUG!

  C、配置Redmine

  以下操作均需要在Redmine所在目录操作。

  切换到redmine目录:

cd /var/www/redmine

  创建数据库配置文件

cp  /var/www/redmine/config/database.yml.example /var/www/redmine/config/database.yml

  修改数据库配置文件中的MySQL数据库的连接信息,将production代码块下的mysql相关信息修改成你对应的数据。

vi  config/database.yml

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

  注:冒号后面的空格必须保留。

  D、创建一个session安装密钥

rake generate_session_store

  E、初始化Redmine的数据库结构

RAILS_ENV=production rake db:migrate

  F、导入缺省配置数据  

RAILS_ENV=production rake redmine:load_default_data

  注:这一步操作是可选的,此命令将导入默认角色、跟踪标签、状态、工作流程和枚举值(强烈推荐执行它),您也可以从头开始一步步填写自己的配置参数。

  G、修改相关文件夹权限

chmod -R 755 files log tmp public/plugin_assets

  H、启动Redmine

  缺省运行在3000端口上

ruby script/server webrick -e production

  也可以用-p参数自定启动端口

ruby script/server -e production -p 80

  让Redmine后台运行

nohup ruby script/server webrick -e production &

  I、使用Redmine

  访问http://ip:3000/,你能看见Redmine的欢迎页。

  你可以使用缺省管理员登陆,缺省管理员用户名为: admin,密码为: admin

  三、其它

  A、SMTP server配置

cp /var/www/redmine/config/configuration.yml.example /var/www/redmine/config/configuration.yml

vi /var/www/redmine/config/configuration.yml

#以GMAIL为例,修改下面配置段
production:
   email_delivery:
     delivery_method: :smtp
     smtp_settings:
       address: smtp.gmail.com
       port: 587
       authentication: :login
       domain: smtp.gmail.com
       user_name: mike@gmail.com
       password: testredmine
       tls: true

  B、备份

  Redmine的备份应该包括:数据(保存在redmine数据库中)和附件(保存在Redmine安装目录的files目录中)

  以下是一个可以进行每天备份的简单脚本程序

#备份数据库
/usr/bin/mysqldump -u  -p  | gzip > /path/to/backup/db/redmine_`date +%y_%m_%d`.gz

#备份附件
rsync -a /path/to/redmine/files /path/to/backup/files

  四、Apache与Redmine整合

  在自带的webrick上运行Redmine,访问速度很可能不能满足使用需求,通过Apache与Redmine整合后,让Redmine运行在Apache上,速度就会快很多。让Apache运行ROR有多种方式,这里使用Passenger模块。

  安装Passenger模块

  A、编译安装

  安装编译所需依赖的环境

apt-get install apache2-prefork-dev libaprutil1-dev libapr1-dev libcurl4-openssl-dev

  编译安装Passenger模块

gem install passenger
passenger-install-apache2-module

  如果报passenger-install-apache2-module这条命令找不到,那么通过下面的命令查看执行路径:

gem environment

RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.5
  - RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
  - INSTALLATION DIRECTORY: /var/lib/gems/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby1.8
  - EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /var/lib/gems/1.8
     - /root/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/

  其中,EXECUTABLE DIRECTORY就是命令的全路径,这里就用全路径来执行命令:

/var/lib/gems/1.8/bin/passenger-install-apache2-module

  接着按提示进行安装和部署。Passenger会在本机编译并成为Apache的一个模块。安装过程中会遇到下面的提示信息(根据版本的不同,信息也会稍有变化)

Welcome to the Phusion Passenger Apache 2 module installer, v3.0.7.

This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.

Here's what you can expect from the installation process:

 1. The Apache 2 module will be installed for you.
 2. You'll learn how to configure Apache.
 3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.

Press Enter to continue, or Ctrl-C to abort.
--------------------------------------------
Checking for required software...

 * GNU C++ compiler... found at /usr/bin/g++
 * Curl development headers with SSL support... found
 * OpenSSL development headers... found
 * Zlib development headers... found
 * Ruby development headers... found
 * OpenSSL support for Ruby... found
 * RubyGems... found
 * Rake... found at /usr/bin/rake
 * rack... found
 * Apache 2... found at /usr/sbin/apache2
 * Apache 2 development headers... found at /usr/bin/apxs2
 * Apache Portable Runtime (APR) development headers... found at /usr/bin/apr-1-config
 * Apache Portable Runtime Utility (APU) development headers... found at /usr/bin/apu-1-config

--------------------------------------------
Compiling and installing Apache 2 module...
#编译过程省略
......
--------------------------------------------
The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
   PassengerRoot /var/lib/gems/1.8/gems/passenger-3.0.7
   PassengerRuby /usr/bin/ruby1.8

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!

Press ENTER to continue.
--------------------------------------------
Deploying a Ruby on Rails application: an example

Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:

   
      ServerName www.yourhost.com
      DocumentRoot /somewhere/public    # <-- be sure to point to 'public'!
      
         AllowOverride all              # <-- relax Apache security settings
         Options -MultiViews            # <-- MultiViews must be turned off
      
   

And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:

  /var/lib/gems/1.8/gems/passenger-3.0.7/doc/Users guide Apache.html

Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
http://www.modrails.com/

Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.

  创建一个加载Passenger模块的Apache配置文件

vi /etc/apache2/mods-enabled/passenger.load

#加入以下内容
LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /var/lib/gems/1.8/gems/passenger-3.0.7
PassengerRuby /usr/bin/ruby1.8

  注:passenger-3.0.7里的版本号需根据实际情况更改,当前(2011/07/05)的更新为passenger-3.07)

  在Apache上创建一个站点

vi /etc/apache2/sites-available/redmine


  ServerName 192.168.1.109
  DocumentRoot /var/www/redmine/public/
  
     AllowOverride all
     Options -MultiViews
  

  注:DocumentRoot的路径为你安装Redmine目录下的public目录。

  启用Redmine站点

a2ensite redmine

  注:这一步其实就是在/etc/apache2/sites-enabled/下创建一个指向/etc/apache2/sites-available/redmine的软链,之所以要这么做是因为Apache主配置文件(/etc/apache2/apache2.conf)中只引入了sites-enabled下的配置文件(Include /etc/apache2/sites-enabled/)。如果你觉得麻烦,可以直接把相应内容加入主配置文件就可以了,分开放是为了看上去结构更清楚一些。

  修改Redmine目录的权限(www-data为Apache的运行用户)

chown -R www-data:www-data /var/www/redmine

  重启Apache

apache2ctl restart

  访问http://ip,你可以看到Redmine的欢迎页。

  B、通过包安装Passenger模块

apt-get install libapache2-mod-passenger

  其它部分与编译安装部分相同。

  五、参考文档

  http://www.google.com
  http://www.hihiyou.com/?p=91
  http://www.xclinux.cn/?p=861
  http://www.redmine.org/projects/redmine/wiki/RedmineInstall
  http://www.swordair.com/docs/config-doc/redmine_complete_config_on_ubuntu.html



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

Comments

7 Responses to “Ubuntu 10.04下安装Redmine”

Leave a Reply

You must be logged in to post a comment.

传奇 似水流年 绽放 风筝 八月照相馆