Redmine is a flexible project management web application. Written using the Ruby on Rails framework, it is cross-platform and cross-database.
Redmine是基于Ruby on Rails框架支持跨平台、跨数据库的一款灵活的项目管理web应用程序。
特性
- 支持多项目管理;
- 灵活的基于角色的访问控制;
- 灵活的问题跟踪系统;
- 通过甘特图和日历追踪事务;
- 新闻、文档和文件管理;
- feeds和邮件通知;
- 依附于项目的wiki;
- 项目论坛;
- 简单实时跟踪功能;
- 自定义字段的问题,时间项,项目和用户;
- SCM in集成 (SVN, CVS, Git, Mercurial, Bazaar and Darcs)
- 多个 LDAP认证支持;
- 用户自注册支持;
- 多语言支持;
- 多数据库支持。
为什么使用Redmine?
基于上面的多种特性,在项目管理工作中,如任务分配、任务跟踪、项目权限管理等等带来很大的便捷性,使得工作进度、质量更加可控。春雨在使用Redmine时集成了ldap,并以此对外部员工(toh、合作方)和内部员工做了区分,同时Redmine对用户分配了四种角色(超级管理员、管理人员、开发人员、报告人员),而且还可以配置用户组,如此一来对于项目权限管理更加便捷。更重要的一点是日常工作中所有工作内容的申请和交接都通过Redmine和email来操作,这样所有工作的开展都有据可依,也符合等保3的考核要求。
安装配置
环境
环境 | 版本 | Ip | Hostname |
---|---|---|---|
系统环境 | centos7 | 192.168.228.130 | host3 |
Redmine | 3.4.6 | - | host3 |
ruby | 2.0.0 | - | host3 |
数据库(mysql) | 5.6 | 192.168.228.129 | host2 |
安装
-
安装依赖:ruby、rake、rails
centos7.3 可以使用yum直接安装ruby,也可以使用rvm安装。在此使用rvm管理ruby,rvm 是一个命令行工具,可以提供一个便捷的多版本 Ruby 环境的管理和切换,如果你打算学习 Ruby / Rails, RVM 是必不可少的工具之一。
# 安装rvm $ gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3 $ curl -L https://get.rvm.io | bash -s stable $ source /etc/profile.d/rvm.sh #set up system environment for Ruby, 这步不可少 $ rvm reload $ rvm install 2.3.3 # rvm的简单用法:安装ruby $ rvm list 查看ruby $ rvm use 2.2.0 使用ruby $ rvm install xxxx 安装一个版本的ruby $ rvm remove xxxx 卸载一个版本的ruby # 安装rake和rails ## 如果嫌默认的ruby源慢,可以使用以下方法进行替换 $ gem source -r https://rubygems.org/ # 删除默认ruby源 $ gem source -a http://mirrors.aliyun.com/rubygems/ # 配置阿里的源 ## 安装 $ gem install rake -v 12.0.0 $ gem install rails -v 4.2.6
-
安装Redmine:
$ wget http://www.redmine.org/releases/redmine-3.4.6.tar.gz $ tar zxvf redmine-3.4.6.tar.gz
-
创建数据库(使用单独的数据库服务器:192.168.228.129):
$ mysql -uroot -p123456 mysql> CREATE DATABASE redmine CHARACTER SET utf8mb4; mysql> CREATE USER 'redmine'@'192.168.228.130' IDENTIFIED BY '123456'; mysql> GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'192.168.228.130'; # 在host3测试连通性,保证数据库能正常访问 $ mysql -uredmine -h192.168.228.129 -P3306 -p123456 MySQL [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | redmine | | test | +--------------------+ 3 rows in set (0.00 sec)
-
配置数据库:
# 进入Redmine配置文件目录 $ cd /usr/local/src/redmine-3.4.6/config # 创建数据库配置文件 $ cp database.yml.example database.yml $ vim database.yml production: adapter: mysql2 database: redmine # 数据库 host: 192.168.228.129 # 数据库服务器 # port: 3307 # 数据库运行端口不是3306时使用该变量指定对应端口 username: redmine # 数据库用户 password: "123456" # 密码 encoding: utf8 # 字符集
-
安装依赖: Redmine通过Bundler管理gems的依赖项。
# 安装bundler $ gem install bundler # 安装Redmine所依赖的gems相关包 $ bundle install --without development test
-
Note: 可选依赖项 && 数据库适配器
RMagick :允许通过ImageMagick操作PDF和PNG导出的图像。如果系统没有安装ImageMagick,在安装Redmine依赖包时需要跳过该项
bundle install --without development test rmagick
。 -
冲突处理:
# 冲突1: An error occurred while installing nokogiri (1.6.8.1), and Bundler cannot continue. # 解决办法: $ yum install -y gcc ruby-devel zlib-devel # 根据输出信息判断,之前没有安装ruby-devel包 # 详情参考:http://www.nokogiri.org/tutorials/installing_nokogiri.html # 冲突2: An error occurred while installing mysql2 (0.4.10), and Bundler cannot continue. # 解决办法: $ yum install -y mysql-devel # 冲突3: An error occurred while installing rmagick (2.16.0), and Bundler cannot continue. # 解决办法: $ yum install ImageMagick-devel # 处理完以上冲突后直接执行 bundle install --without development test 安装完成!
-
-
session加密处理: 创建随机key对session加密,防止被篡改
$ bundle exec rake generate_secret_token
-
初始化数据库字段:
$ RAILS_ENV=production bundle exec rake db:migrate
-
冲突解决(首先确保数据库字符集为utf8mb4):
# 冲突1:key太长 Mysql2::Error: Specified key was too long; max key length is 767 bytes: CREATE INDEX `wiki_pages_wiki_id_title` ON `wiki_pages` (`wiki_id`, `title`) # 解决办法: $ vim config/initializers/ar_innodb_row_format.rb ActiveSupport.on_load :active_record do module ActiveRecord::ConnectionAdapters class AbstractMysqlAdapter def create_table_with_innodb_row_format(table_name, options = {}) table_options = options.reverse_merge(:options => 'ENGINE=InnoDB ROW_FORMAT=DYNAMIC') create_table_without_innodb_row_format(table_name, table_options) do |td| yield td if block_given? end end alias_method_chain :create_table, :innodb_row_format end end end # 更改mysql配置: $ mysql -uroot -p123456 set global innodb_large_prefix = 1 set global innodb_file_format = barracuda set global innodb_file_per_table = 1 # 然后重新导入数据即可!!! # 参考: # http://www.redmine.org/issues/23586 (个人使用方法1) # 类似问题:http://www.redmine.org/boards/2/topics/54308?r=54309
Note: 数据库相关配置写入/etc/my.cnf下,避免服务重启后配置被还原。
-
-
数据初始化:
$ RAILS_ENV=production bundle exec rake redmine:load_default_data ## 该过程会以交互形式让用户选择语言环境变量,也可以在执行该命令时直接指定环境变量,如下: $ RAILS_ENV=production REDMINE_LANG=zh bundle exec rake redmine:load_default_data
-
文件系统授权: 运行Redmine的用户需要对以下目录文件有写权限。出于安全考虑,app使用普通用户运行,所以在此需要先创建redmine用户。授权目录如下:
- files:存储附件文件
- log:存放应用日志
- tmp 和 tmp/pdf:如果目录文件不存在需要手动创建,用于创建PDF文件
- public/plugin_assets:存放插件
$ mkdir -p /usr/local/src/tmp/pdf /usr/local/src/public/plugin_assets $ chown -R redmine:redmine /usr/local/src/redmine-3.4.6 $ cd /usr/local/src/redmine-3.4.6 # 执行以下操作前请先备份/usr/local/src/redmine-3.4.6 $ chmod -R 755 files log tmp public/plugin_assets # 官方Note: If you have files in these directories (e.g. restore files from backup), make sure these files are not executable.(如果这些目录下有文件,需要去除其执行权限!!!) $ find files log tmp public/plugin_assets -type f -exec chmod -x {} +
-
测试(该测试不支持生产环境):
$ bundle exec rails server webrick -e production
-
启动Redmine:
/usr/local/rvm/rubies/ruby-2.3.3/bin/ruby /usr/local/src/redmine-3.4.6/bin/rails server webrick -e production -d
-
加入systemctl管理:
$ vim /usr/lib/systemd/system/redmine.service [Unit] Description=Redmine Control After=syslog.target After=network.target [Service] User=redmine Group=redmine WorkingDirectory=/usr/local/src/redmine-3.4.6/ ExecStart=/usr/local/rvm/rubies/ruby-2.3.3/bin/ruby /usr/local/src/redmine-3.4.6/bin/rails server webrick -e production server webrick -e production Restart=on-failure RestartSec=10 [Install] WantedBy=multi-user.target # 启动Redmine: $ systemctl start redmine
-
冲突解决:
# 冲突: Sep 26 00:06:24 host3 ruby: /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.5/lib/bundler/spec_set.rb:91:in `block in material ize': Could not find rmagick-2.16.0 in any of the sources (Bundler::GemNotFound) # 原因:在本地找不到gem文件 # 解决办法: $ bundle install --path vendor/cache # 将gem缓存到本地
-
-
检查Redmine运行状态:
Note: Due to a change in Rack,
rails server
now listens onlocalhost
instead of0.0.0.0
by default. Thisshould have minimal impact on the standard development workflow as both
http://127.0.0.1:3000 and http://localhost:3000 will continue to work as before
on your own machine.
However, with this change you will no longer be able to access the Rails
server from a different machine, for example if your development environment
is in a virtual machine and you would like to access it from the host machine.
In such cases, please start the server with
rails server -b 0.0.0.0
torestore the old behavior.
即, 新版本的Redmine启动后默认监听localhost,如果要通过外网访问,需要在启动时指定其监听的ip。如果不指定,需要在本机配置代理(nginx/httpd)。
本文来源: vendor/cache/ruby/2.3.0/gems/rails-4.2.8/guides/source/4_2_release_notes.md
# 检测方法1: $ curl http://192.168.228.130:3000 -I # 返回200状态码 # 检测方法2:配置代理,通过浏览器访问 ## nginx相关配置如下: $ cat /usr/local/nginx/conf/servers/redmine/upstream.conf upstream backserver { server 127.0.0.1:3000; } $ cat /usr/local/nginx/conf/servers/redmine/site.conf server { listen 80; server_name redmine.localhost.com; location / { #配置代理 proxy_pass http://backserver; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } # 在浏览器访问192.168.228.130 (注意,在测试环境使用该方法测试的前提是保证该虚拟主机为当前nginx服务器的默认虚拟主机,否则需要配置独立域名),结果如下:
至此,Redmine安装完成!
配置及使用
登录
初始管理员用户名:admin 密码:admin
首次登陆后会要求更改管理员密码:
更改密码(12345678)后可以看到管理员用户的相关信息:
功能介绍
管理员可以通过web界面直接管理Redmine大部分配置:
-
基础配置:
-
邮件服务:
-
Note: 邮件通知功能需要登录服务器编辑配置文件
config/configuration.yml
开启配置后方可在此编辑。email_delivery: delivery_method: :sendmail # 在此使用sendmail作为邮件服务器 # ==== Simple SMTP server at localhost (使用本地邮件服务器) # # email_delivery: # delivery_method: :smtp # smtp_settings: # address: "localhost" # port: 25 # # ==== SMTP server at example.com using LOGIN authentication and checking HELO for foo.com (使用指定的邮件服务器) # # email_delivery: # delivery_method: :smtp # smtp_settings: # address: "example.com" # port: 25 # authentication: :login # domain: 'foo.com' # user_name: 'myaccount' # password: 'password'
参考: http://www.redmine.org/projects/redmine/wiki/EmailConfiguration
配置完成后,重启服务,web访问如下:
-
-
ldap认证: 如果公司使用ldap管理员工账号,Redmine内置了ldap集成功能,配置方法如下。
-
数据备份及恢复:
- 数据库备份(stored in your redmine database)
- 附件备份 (stored in the
files
directory of your Redmine install) - 参考: http://www.redmine.org/projects/redmine/wiki/RedmineBackupRestore
忘记管理员密码
因为长时间不用,忘记了管理员密码,且部署时更改初始密码后没记录,所以需要通过后台来重置密码,方法如下:
# 进入部署目录
$ cd /usr/local/src/redmine-3.4.6/
# 进入ruby
$ ./bin/rails console production
进入ruby后操作:
# 获取要修改的用户
2.3.0 :001 > admin_user = User.find_by_login('admin')
# 设置新密码
2.3.0 :005 > admin_user.password='12345678' # 注:此处密码最小8位
# 保存
2.3.0 :006 > admin_user.save!
=> true
# 退出
2.3.0 :007 > quit
然后再web端重新登录即可!
Redmine安装插件
往往随着需求的不断调整,对于功能的要求也就越来越多,所以作为运维,随时都面临着对已有工具升级、打补丁、装插件等工作。
- Redmineg官方插件 下载地址 ,更多的插件可以到github查找并下载, 示例 。
- 安装插件(以插件redmine_angile为例):
- 下载插件到
$(REDMINE_ROOT)/plugins/
下,并解压; - 安装依赖的gems包(需要先切换至Redmine运行目录):
cd $(REDMINE_ROOT) && bundle install --without development test --no-deployment --path vendor/cache
; - 切换至redmine用户 (必须有该操作,否则将因文件权限问题导致服务不可用);
- 更新数据库
bundle exec rake redmine:plugins NAME=redmine_agile RAILS_ENV=production
;- 冲突: 如果出现“找不到“.bundle/ ”文件”的错误信息,原因是执行命令时所在路径不对,切换至
/usr/local/src/redmine
重新执行即可!
- 冲突: 如果出现“找不到“.bundle/ ”文件”的错误信息,原因是执行命令时所在路径不对,切换至
- 重启Redmine服务
systemctl restart redmine
;
- 下载插件到
- 配置插件:
- 查看插件功能:
- 参考: