官方安装文档:http://www.redmine.org/projects/redmine/wiki/RedmineInstall
创建数据库
CREATE DATABASE redmine CHARACTER SET utf8;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
安装redmine主体
https://www.redmine.org/releases/redmine-4.2.6.tar.gz
tar -xzvf redmine-4.2.6.tar.gz
cd redmine-4.2.6
cp config/database.yml.example config/database.yml
vim config/database.yml
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "password"
encoding: utf8
show global variables like ‘port’; 非3306 需
production:
adapter: mysql2
database: redmine
host: localhost
port: 3307
username: redmine
password: "password"
encoding: utf8
编译安装ruby
https://www.ruby-lang.org/en/news/
tar -xzvf ruby-2.5.5.tar.gz
cd ruby-2.5.5
mkdir -p /usr/local/ruby
./configure --prefix=/usr/local/ruby
make && make install
ruby --version #检测ruby是否安装正常
ln -s /usr/local/ruby/bin/ruby /usr/local/bin/ruby
export PATH=$PATH:/usr/local/ruby/bin
安装rubygem
https://rubygems.org/pages/download
tar -xzvf rubygems-3.3.14.tar.gz
cd rubygems-3.3.14
ruby setup.rb
gem -v
安装bundler
gem install bundler
gem install rubyzip
cd /usr/local/redmine-4.0.2
方案1:
安装ImageMagick-6.9.8-3.tar.gz
./configure --prefix=/usr/local/ImageMagic
make && make install
echo '/usr/local/ImageMagic/lib/' >> /etc/ld.so.conf.d/server.conf
ldconfig
strings /etc/ld.so.cache |grep ImageMagic
vim /etc/profile
echo $PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/ImageMagic/lib/pkgconfig/:$PKG_CONFIG_PATH
bundle install --without development test
方案2:
RMagick (allows the use of ImageMagick to manipulate images for PDF and PNG export)
bundle install --without development test rmagick
创建会话密钥
bundle exec rake generate_secret_token
创建数据库结构
RAILS_ENV=production bundle exec rake db:migrate
插入默认配置数据库中的数据
RAILS_ENV=production bundle exec rake redmine:load_default_data
选择系统语言
Select language: ar, bg, bs, ca, cs, da, de, el, en, en-GB, es, 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
权限管理
mkdir -p tmp tmp/pdf public/plugin_assets
chmod -R 755 files log tmp public/plugin_assets
sudo find files log tmp public/plugin_assets -type f -exec chmod -x {} +
启动:
nohup bundle exec rails server webrick -e production -b 0.0.0.0 &
浏览器访问:192.168.110.110:3000
login: admin
password: admin
无法登录时,需要开放3000端口
vim /etc/sysconfig/iptables
/etc/init.d/iptables restart
firewall-cmd –zone=public –add-port=3000/tcp –permanent
firewall-cmd –reload
启动:
ps -ef |grep ruby
kill Port
nohup bundle exec rails server webrick -e production -b 0.0.0.0 &
vim nohup.txt 检查是否报错
以下是init 脚本代码:
#!/bin/sh
#
# redmine Redmine Daemon
#
# chkconfig: - 99 36
# description: Remine Daemon
. /etc/rc.d/init.d/functions
HOMEPATH=/usr/local/redmine-4.2.6
PIDFILE=$HOMEPATH/tmp/pids/server.pid
PARAMS="-e production -b 0.0.0.0 -d"
SERVER=webrick
cd $HOMEPATH
start(){
echo 'Starting redmine...'
/usr/local/ruby/bin/bundle exec /usr/local/ruby/bin/rails server $SERVER $PARAMS
RETVAL=$?
return $RETVAL
}
stop(){
echo -n 'Stopping redmine...'
killproc -p $PIDFILE -INT
RETVAL=$?
return $RETVAL
}
status(){
echo -n 'Redmine is '
if [ -f $PIDFILE ]
then
PID=`/bin/cat $PIDFILE`
STATUS=`/bin/ps -p $PID`
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
echo 'running.'
return $RETVAL
fi
fi
echo 'not running.'
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
echo
;;
status)
status
;;
*)
echo "Usage $0 {start|stop|status|restart}"
exit 1
esac
将以上脚本保存为 /etc/init.d/redmine 后,就可以使用 chkconfig 来配置随系统启动了:
chmod +x /etc/init.d/redmine
chkconfig –add redmine
chkconfig redmine on
重启脚本:
cat > redmine.sh <<EOF
#/bin/bash
# redmine 启动
#——————
kill $(cat /usr/local/redmine-3.3.0/tmp/pids/server.pid)
nohup /usr/local/bin/bundle exec /usr/local/bin/rails server webrick -e production -b 0.0.0.0 &
EOF
备份和恢复
备份和恢复 是企业应用中永远存在的话题.
Redmine的用户和问题等信息存储于Mysql数据库,表名为redmine而附件等资源存储于Redmine安装目录的files目录下.
因此需要迁移的话只需要备份Mysql数据库的对应的表和files目录即可。
1.备份mysql数据库。
查看redmine/mysql/config/database.yml
记住production字段的username和password。
然后控制台root权限执行:mysqldump -u username -p passwd redmine > /path/redmine_bak.sql
然后是备份附件。
$ cd redmine
$ tar cvzf /var/files_bak.tar.gz ./files/
2、Redmine恢复
附件库恢复
直接将备份的/var/files_bak.tar.gz解压缩到/redmine/files目录下即可
Mysql恢复
在root用户下运行:
$ mysql -u root -p redmine < /var/redmine_bak.sql
3、恢复完毕后启动Redmine,
$ cd redmine
$ ruby script/server -e production
如果页面有乱码,可编辑redmine/mysql/config/database.yml,将production字段的encoding注释掉即可。