安装 Ruby 2.4

yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison ImageMagick-devel  ImageMagick
yum -y install centos-release-scl-rh
yum -y install rh-ruby24 
scl enable rh-ruby24 bash
ruby -v 
yum -y install rh-ruby24-rubygems rh-ruby24-ruby-devel
gem source -l
gem sources -a http://mirrors.aliyun.com/rubygems/
gem sources --remove  https://rubygems.org/
gem source -u
gem source -l 

设置数据库

建立相应数据库

mysql> create user 'redmine'@'%' identified by '123456' ;
mysql> create database redmine;
mysql> grant all on redmine.* to 'redmine'@'%';
mysql> flush privileges;

安装 redmine

cd /usr/local
wget https://www.redmine.org/releases/redmine-4.0.4.tar.gz
tar zxvf redmine-4.0.4.tar.gz
mv redmine-4.0.4 redmine
echo "export REDMINE=/usr/local/redmine" >> /etc/profile
source /etc/profile
cd $REDMINE
cp config/database.yml.example config/database.yml

配置 redmine,修改 $REDMINE/config/database.yml

production:
  adapter: mysql2
  database: redmine
  host: localhost
  port: 3306
  username: redmine
  password: "123456"

安装 GEMS 依赖

cd $REDMINE
gem install bundler
bundle install --without development test production 

生成会话存储秘钥令牌

bundle exec rake generate_secret_token

生成数据库结构

RAILS_ENV=production REDMINE_LANG=zh bundle exec rake db:migrate

数据库插入默认数据

RAILS_ENV=production REDMINE_LANG=zh bundle exec rake redmine:load_default_data

启动 redmine

bundle exec rails server webrick -e production -b 127.0.0.1

配置 LDAP 认证

依次打开 管理 -> LDAP 认证 -> 新建认证模式

配置一个 ou=admin 的配置如下:

同样的方法配置所需要的所有 ou,如下图所示:

配置 CAS SSO

安装插件

cd $REDMINE/plugins
git clone https://github.com/athlonreg/redmine_omniauth_cas
cd redmine_omniauth_cas
bundle install
cd $REDMINE
bundle install
RAILS_ENV=production rake redmine:plugins
bundle exec rails server webrick -e production -b 127.0.0.1

依次打开 管理 -> 插件,点击插件 Redmine Omniauth plugin 后的配置

配置如下:

各字段含义对照表

字段名称 字段含义
Enable CAS authentication 是否启用 CAS 认证
CAS server URL CAS 服务器地址
CAS validation URL (if different) CAS 服务器身份验证接口地址
Login page text 登陆页面标题
Replace Redmine login page 是否使用 CAS 服务器的登陆界面替换插件提供的登录界面