1. 程式人生 > >CentOS上安裝Redmine-3.4項目管理軟件

CentOS上安裝Redmine-3.4項目管理軟件

redmine

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數據庫

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

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

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

root@node1 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的命令。
[root@node1 ~]# 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的命令。

[root@node1 ~]# 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。
[root@node1 ~]# 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命令。
[root@node1 ~]# source /usr/local/rvm/scripts/rvm

查看rvm庫中已知的ruby版本
[root@node1 ~]# 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
[root@node1 ~]# rvm install  2.4.1

#使用新版本
[root@node1 ~]# rvm use  2.4.1

#查看當前版本
[root@node1 ~]# ruby --version

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

請盡可能用比較新的 RubyGems 版本,建議 2.6.x 以上。
[root@node1 ~]# gem update --system  # 這裏請×××一下
[root@node1 ~]# gem -v
2.6.14
[root@node1 ~]# gem sources -l       # 查看當前鏡像源 
https://rubygems.org/
[root@node1 ~]# gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
[root@node1 ~]# gem sources -l
https://gems.ruby-china.org
# 確保只有 gems.ruby-china.org

如果你使用 Gemfile 和 Bundler (例如:Rails 項目)
你可以用 Bundler 的 Gem 源代碼鏡像命令。
[root@node1 ~]# 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 和 相關依賴包

[root@node1 ~]# gem install rails  
[root@node1 ~]# gem install rake  
[root@node1 ~]# gem install mysql2

8.下載redmine並安裝依賴

[root@node1 ~]# yum install ImageMagick-devel
[root@node1 ~]# useradd -s /sbin/nologin redmine
[root@node1 ~]# cd /usr/local/  
[root@node1 local]# wget http://www.redmine.org/releases/redmine-3.4.4.tar.gz
[root@node1 local]# tar xf redmine-3.4.4.tar.gz
[root@node1 local]# mv redmine-3.4.4 redmine && cd redmine 
[root@node1 local]# chown -R root:root /usr/local/redmine   
[root@node1 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的文件中定義。
[root@node1 ~]# cd /usr/local/redmine/config/
[root@node1 config]# cp configuration.yml{.example,}
[root@node1 config]# cp database.yml{.example,}
[root@node1 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

[root@node1 config]# cd ../
[root@node1 redmine]# rake generate_secret_token  
[root@node1 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) =======

[root@node1 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.
[root@node1 redmine]#

權限設置:

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

10.啟動redmine

[root@node1 ~]# 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項目管理軟件