今天在测试笔记本上试装了redmine,准备用它做自研项目的管理软件,主要根据官方文档和另一篇文章来安装,途中也经历了一些 文章没记录的错误,经过一番摸索后安装成功,这里做个总结。
安装环境是Centos6.9,已安装Aphache,PHP,MySQL5.5.32,有需要的应该只有MySQL。
先在官网上下载了软件包:redmine-3.4.5.tar.gz
官网安装说明文档:http://www.redmine.org/projects/redmine/wiki/RedmineInstall
因为机子上已有MySQL,这里就省略这部分安装,需要说明的是我的MySQL做了多实例,所以后面的Socket配置会和常规稍有不同。
设置mysql的账号[root@node1 mysql]和密码,并创建redmine数据库
[root@node1 mysql]
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)
安装rvm
curl -L get.rvm.io | bash -s stable
如果遇到以下报错,则执行报错中的gpg2 –recv-keys的命令
[root@node1 ~]
% 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 ~]
gpg: 钥匙环‘
/root/
.gnupg
/secring
.gpg’已建立
gpg: 下载密钥‘D39DC0E3’,从 hkp 服务器 keys.gnupg.net
gpg:
/root/
.gnupg
/trustdb
.gpg:建立了信任度数据库
gpg: 密钥 D39DC0E3:公钥“Michal Papis (RVM signing) <mpapis@gmail.com>”已导入
gpg: 没有找到任何绝对信任的密钥
gpg: 合计被处理的数量:1
gpg: 已导入:1 (RSA: 1)
再次执行命令curl -L get.rvm.io | bash -s stable。
[root@node1 ~]
% 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) <mpapis@gmail.com>”
gpg: 亦即“Michal Papis <michal.papis@toptal.com>”
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 ~]
查看rvm库中已知的ruby版本
[root@node1 ~]
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-
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
... ...
安装Ruby
[root@node1 ~]
[root@node1 ~]
[root@node1 ~]
如果gem的源所在的网络不好,可以更改源
请尽可能用比较新的 RubyGems 版本,建议 2.6.x 以上。
[root@node1 ~]
[root@node1 ~]
2.6.14
[root@node1 ~]
https:
//rubygems
.org/
[root@node1 ~]
[root@node1 ~]
https:
//gems
.ruby-china.org
如果你使用 Gemfile 和 Bundler (例如:Rails 项目)
你可以用 Bundler 的 Gem 源代码镜像命令。
[root@node1 ~]
这样你不用改你的 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。
安装rails 和 相关依赖包
[root@node1 ~]
[root@node1 ~]
[root@node1 ~]
下载redmine并安装依赖
[root@node1 ~]
[root@node1 ~]
[root@node1 ~]
[root@node1
local
]
[root@node1
local
]
[root@node1
local
]
[root@node1
local
]
[root@node1 redmine]
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"
--------------------------------------------------------
配置redmine并初始化
[root@node1 ~]
[root@node1 config]
[root@node1 config]
[root@node1 config]
production:
adapter: mysql2
database: redmine
host: localhost
port: 3306
socket:
/data/3306/mysql
.sock
username: redmine
password:
"my_password"
encoding:
utf8mb4 //这里应填utf
8
[root@node1 config]
[root@node1 redmine]
[root@node1 redmine]
== 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]
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]
在此步骤报了个错:
Error: unknown attribute ‘issues_visibility’ for Role.
我做了如下处理后得到解决:
1.把数据库中redmine库的字符集从原来设置的utf8mb4改为utf8;
2.把redmine库里自动生成的表全部清空,重新生成。这里用了个批理删除方法:
SELECT CONCAT(‘TRUNCATE TABLE ‘,TABLE_NAME,’;’) FROM information_schema.TABLES WHERE TABLE_SCHEMA=’test’ into outfile ‘/tmp/truncate_test.sql’;
source /tmp/truncate_test.sql
3.再运行上面命令重新初始化redmine库。
RAILS_ENV=production bundle exec rake db:migrate #生成表结构
RAILS_ENV=production bundle exec rake redmine:load_default_data # 初始化数据选择zh
这次成功执行。
权限设置:
[root@node1 redmine]
/usr/local/redmine
[root@node1 redmine]
[root@node1 redmine]
[root@node1 redmine]
启动redmine
[root@node1 ~]#/usr/local/redmine/bin/rails server -e production -b 192.168.1.10
访问登录
访问 http://ip:3000/
默认账号和密码 admin admin
后续备份:
主要是备份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