CentOS上安装Redmine-3.4项目管理软件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS上安装Redmine-3.4项目管理软件相关的知识,希望对你有一定的参考价值。

1.说明
redmine和ruby以及rails的版本号关系如下: 
Redmine版本         支持Ruby版本                         使用Rails版本
4.0 (即将到来的)     ruby 2.2,2.3,2.4                    Rails 5.1
3.4                 ruby 1.9.3,2.0.0,2.1,2.2,2.3,2.4    Rails 4.2
3.3                 ruby 1.9.3,2.0.0,2.1,2.2,2.3        Rails 4.2
3.2                 ruby 1.9.3.2.0.0,2.1,2.2            Rails 4.2

支持Ruby 1.9.3,2.0和2.1通过Ruby社区已经结束。 
Redmine 3.2或更低的不支持Ruby 2.3 。 Redmine 3.3支持Ruby 2.3。
Redmine不支持JRuby 因为一些gems不支持Rails 4.2。

官方安装文档:http://www.redmine.org/projects/redmine/wiki/RedmineInstall

redmine安装思路:mysql --> RVM --> ruby --> gem --> rails --> redmine

注:SELinux和防火墙要关闭;

2.安装mysql

mysql5.7.15二进制安装,详见我的另一篇博客:

http://blog.51cto.com/moerjinrong/2092614

3.设置mysql的账号和密码,并创建redmine数据库

[[email protected] mysql]# mysql  -uroot -p
[email protected] 14:18:  [(none)]> create database redmine character set utf8;
Query OK, 1 row affected (0.01 sec)

[email protected] 14:29:  [(none)]> create user 'redmine'@'localhost' IDENTIFIED BY 'my_password';
Query OK, 0 rows affected (0.00 sec)

[email protected] 14:29:  [(none)]> grant all privileges on redmine.* to 'redmine'@'localhost';
Query OK, 0 rows affected (0.00 sec)

[email protected] 14:30:  [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

4.安装rvm

curl -L get.rvm.io | bash -s stable

如果遇到以下报错,则执行报错中的gpg2 --recv-keys的命令。
[[email protected] ~]# curl -L get.rvm.io | bash -s stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   194  100   194    0     0    335      0 --:--:-- --:--:-- --:--:--   335
100 24090  100 24090    0     0  17421      0  0:00:01  0:00:01 --:--:-- 44446
Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc
gpg: 于 2017年09月11日 星期一 04时59分21秒 CST 创建的签名,使用 RSA,钥匙号 BF04FF17
gpg: 无法检查签名:没有公钥
Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found. Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).

GPG signature verification failed for '/usr/local/rvm/archives/rvm-1.29.3.tgz' - 'https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc'! Try to install GPG v2 and then fetch the public key:

    gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3        # 报错执行这个命令
or if it fails:

    command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
the key can be compared with:

    https://rvm.io/mpapis.asc
    https://keybase.io/mpapis
NOTE: GPG version 2.1.17 have a bug which cause failures during fetching keys from remote server. Please downgrade or upgrade to newer version (if available) or use the second method described above.

执行报错中的gpg2 --recv-keys的命令。

[[email protected] ~]# gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
gpg: 钥匙环‘/root/.gnupg/secring.gpg’已建立
gpg: 下载密钥‘D39DC0E3’,从 hkp 服务器 keys.gnupg.net
gpg: /root/.gnupg/trustdb.gpg:建立了信任度数据库
gpg: 密钥 D39DC0E3:公钥“Michal Papis (RVM signing) <[email protected]>”已导入
gpg: 没有找到任何绝对信任的密钥
gpg: 合计被处理的数量:1
gpg:           已导入:1  (RSA: 1)

再次执行命令curl -L get.rvm.io | bash -s stable。
[[email protected] ~]# curl -L get.rvm.io | bash -s stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   194  100   194    0     0    310      0 --:--:-- --:--:-- --:--:--   309
100 24090  100 24090    0     0  18230      0  0:00:01  0:00:01 --:--:--  103k
Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc
gpg: 于 2017年09月11日 星期一 04时59分21秒 CST 创建的签名,使用 RSA,钥匙号 BF04FF17
gpg: 完好的签名,来自于“Michal Papis (RVM signing) <[email protected]>”
gpg:               亦即“Michal Papis <[email protected]>”
gpg:               亦即“[jpeg image of size 5015]”
gpg: 警告:这把密钥未经受信任的签名认证!
gpg:       没有证据表明这个签名属于它所声称的持有者。
主钥指纹: 409B 6B17 96C2 7546 2A17  0311 3804 BB82 D39D C0E3
子钥指纹: 62C9 E5F4 DA30 0D94 AC36  166B E206 C29F BF04 FF17
GPG verified '/usr/local/rvm/archives/rvm-1.29.3.tgz'
Creating group 'rvm'

Installing RVM to /usr/local/rvm/
Installation of RVM in /usr/local/rvm/ is almost complete:

  * First you need to add all users that will be using rvm to 'rvm' group,    
and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.

  * To start using RVM you need to run `source /etc/profile.d/rvm.sh`    
in all your open shell windows, in rare cases you need to reopen all shell windows.

以上表示执行成功,然后加载一下rvm命令。
[[email protected] ~]# source /usr/local/rvm/scripts/rvm

查看rvm库中已知的ruby版本
[[email protected] ~]# rvm list known
    # MRI Rubies
    [ruby-]1.8.6[-p420]
    [ruby-]1.8.7[-head] # security released on head
    [ruby-]1.9.1[-p431]
    [ruby-]1.9.2[-p330]
    [ruby-]1.9.3[-p551]
    [ruby-]2.0.0[-p648]
    [ruby-]2.1[.10]
    [ruby-]2.2[.7]
    [ruby-]2.3[.4]
    [ruby-]2.4[.1]
    ruby-head
    ... ...

5.安装Ruby

#安装ruby
[[email protected] ~]# rvm install  2.4.1

#使用新版本
[[email protected] ~]# rvm use  2.4.1

#查看当前版本
[[email protected] ~]# ruby --version

6.如果gem的源所在的网络不好,可以更改源

请尽可能用比较新的 RubyGems 版本,建议 2.6.x 以上。
[[email protected] ~]# gem update --system  # 这里请×××一下
[[email protected] ~]# gem -v
2.6.14
[[email protected] ~]# gem sources -l       # 查看当前镜像源 
https://rubygems.org/
[[email protected] ~]# gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
[[email protected] ~]# gem sources -l
https://gems.ruby-china.org
# 确保只有 gems.ruby-china.org

如果你使用 Gemfile 和 Bundler (例如:Rails 项目)
你可以用 Bundler 的 Gem 源代码镜像命令。
[[email protected] ~]# bundle config mirror.https://rubygems.org https://gems.ruby-china.org

这样你不用改你的 Gemfile 的 source。
source 'https://rubygems.org/'
gem 'rails', '4.2.5'
...
SSL 证书错误
正常情况下,你是不会遇到 SSL 证书错误的,除非你的 Ruby 安装方式不正确。
如果遇到 SSL 证书问题,你又无法解决,请修改 ~/.gemrc 文件,增加 ssl_verify_mode: 0 配置,以便于 RubyGems 可以忽略 SSL 证书错误。

---
:sources:
- https://gems.ruby-china.org
:ssl_verify_mode: 0

如果你在意 Gem 下载的安全问题,请正确安装 Ruby、OpenSSL,建议部署 Linux 服务器的时候采用 这个 RVM 安装脚本 的方式安装 Ruby。

7.安装rails 和 相关依赖包

[[email protected] ~]# gem install rails  
[[email protected] ~]# gem install rake  
[[email protected] ~]# gem install mysql2

8.下载redmine并安装依赖

[[email protected] ~]# yum install ImageMagick-devel
[[email protected] ~]# useradd -s /sbin/nologin redmine
[[email protected] ~]# cd /usr/local/  
[[email protected] local]# wget http://www.redmine.org/releases/redmine-3.4.4.tar.gz
[[email protected] local]# tar xf redmine-3.4.4.tar.gz
[[email protected] local]# mv redmine-3.4.4 redmine && cd redmine 
[[email protected] local]# chown -R root:root /usr/local/redmine   
[[email protected] redmine]# bundle install
    Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
    The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32`.
    Fetching gem metadata from https://rubygems.org/..........
    Fetching gem metadata from https://rubygems.org/.
    Resolving dependencies....
    Using rake 12.3.1
    ... ...
    Use `bundle info [gemname]` to see where a bundled gem is installed.
    Post-install message from yard:
    --------------------------------------------------------------------------------
    As of YARD v0.9.2:

    RubyGems "--document=yri,yard" hooks are now supported. You can auto-configure
    YARD to automatically build the yri index for installed gems by typing:

        $ yard config --gem-install-yri

    See `yard config --help` for more information on RubyGems install hooks.

    You can also add the following to your .gemspec to have YARD document your gem
    on install:

        spec.metadata["yard.run"] = "yri" # use "yard" to build full html docs.

    --------------------------------------------------------

9.配置redmine并初始化

Redmine设置在config / configuration.yml的文件中定义。
[[email protected] ~]# cd /usr/local/redmine/config/
[[email protected] config]# cp configuration.yml{.example,}
[[email protected] config]# cp database.yml{.example,}
[[email protected] config]# vim database.yml   #选择production部分修改数据库密码  
    production:
      adapter: mysql2
      database: redmine
      host: localhost
      port: 3306                            
      socket: /data/mysql/mysql3306.sock
      username: redmine
      password: "my_password"
      encoding: utf8

[[email protected] config]# cd ../
[[email protected] redmine]# rake generate_secret_token  
[[email protected] redmine]# RAILS_ENV=production bundle exec rake db:migrate    #生成表结构 
    == 1 Setup: migrating =========================================================
    -- create_table("attachments", {:force=>true})
       -> 0.0363s
    -- create_table("auth_sources", {:force=>true})
       -> 0.0231s
    ... ...
    == 20170419144536 AddViewMessagesToAllExistingRoles: migrating ================
    == 20170419144536 AddViewMessagesToAllExistingRoles: migrated (0.0170s) =======

[[email protected] redmine]# RAILS_ENV=production bundle exec rake redmine:load_default_data       # 初始化数据选择zh 
    Select language: ar, az, bg, bs, ca, cs, da, de, el, en, en-GB, es, es-PA, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] zh
    ====================================
    Default configuration data loaded.
[[email protected] redmine]#

权限设置:

[[email protected] redmine]# pwd
 /usr/local/redmine
[[email protected] redmine]# mkdir -pv  tmp tmp/pdf public/plugin_assets
[[email protected] redmine]# chown -R redmine:redmine files log tmp public/plugin_assets
[[email protected] redmine]# chmod -R 755 files log tmp public/plugin_assets

10.启动redmine

[[email protected] ~]# nohup /usr/local/rvm/rubies/ruby-2.4.1/bin/ruby /usr/local/redmine/bin/rails server -e production -b 0.0.0.0 >/dev/null 2>&1 &

11.访问登录

访问 http://ip:3000/
默认账号和密码 admin admin

12.后续备份:

主要是备份mysql的redmine库,config下面的yml配置文件,以及files下面的附件:
#!/bin/bash
bk_time=`date +"%Y%m%d"`

cd /usr/local/redmine
tar -zcf /home/redmine/redmine_backup/conf_file_${bk_time}.tar.gz files/ config/*.yml

mysqldump -u**** -p"****" redmine |gzip > /home/redmine/mysql_backup/redmine_${bk_time}.sql.gz

参考

https://blog.csdn.net/linxi7/article/details/79216859

报错:

1.ERROR RuntimeError: Missing `secret_token` and `secret_key_base` for 'production' environment, set these values in `config/secrets.yml`
解决:
    执行:bundle exec rake generate_secret_token


以上是关于CentOS上安装Redmine-3.4项目管理软件的主要内容,如果未能解决你的问题,请参考以下文章

安装centos8.4解决软碟通制作启动盘安装源无法识别

Centos 6 软Raid创建与管理

如何使用星号将 X-Lite 软电话从主机连接到来宾 vm?

centos 上安装nodejs v8.0.0

2块硬盘,在centos上利用software raid1 做成软raid,为啥拔掉/dev/sda这块硬盘后,系统无法进入?

r5s安装centos8