RHEL 7.0 上安装 Redmine 3.0.1 并随系统自动启动

# <user>
useradd redmine
passwd redmine
chown -R redmine:redmine /home/redmine/app/redmine
chmod -R 755 /home/redmine/app/redmine
tar zxvf redmine-3.0.1.tar.gz
mkdir /home/redmine/app/
mv redmine-3.0.1 /home/redmine/app/redmine

# <database>
mysql -u root -p
create database redmine character set 'utf8';
create user 'redmine'@'localhost' identified by 'red1234';
grant all privileges on redmine.* to 'redmine'@'localhost';
cd /home/redmine/app/redmine/config
cp database.yml.example database.yml
vim database.yml
production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine
  password: red1234

# <yum>
# need to download from http://rpm.pbone.net/ and upload to current dir
yum install ghostscript-devel-*el7.x86_64.rpm
yum install jasper-devel-*el7.x86_64.rpm
yum install ruby-devel-*.rpm
yum install libxml2-devel-*el7.x86_64.rpm
yum install libxslt-devel-*el7.x86_64.rpm

# <bundle>
# log in with user redmine
cd /home/redmine/app/redmine
vim Gemfile
source 'https://ruby.taobao.org/'
gem install bundler
bundle config build.nokogiri --use-system-libraries
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

# <permission>
# log in with root
cd /home/redmine/app/redmine
mkdir -p tmp tmp/pdf public/plugin_assets
chown -R redmine:redmine files log tmp public/plugin_assets
chmod -R 755 files log tmp public/plugin_assets
vim /etc/sysconfig/iptables # add 3000 port
systemctl restart iptables

# <run>
# login with redmine
cd ~/app/redmine/
ruby bin/rails server webrick -e production -d -b=0.0.0.0
# http://<ip>:3000/, admin/admin

# <autostart>
touch /etc/init.d/redmine
vim redmine

#!/bin/sh
REDMINE_HOME=/home/redmine/app/redmine
LOG=$REDMINE_HOME/sysv-redmine.log

case "$1" in
  start)
    echo "redmine start begin"
    date +"%T %a %d: redmine start begin" >> $LOG 2>&1
    su - redmine -c "cd $REDMINE_HOME &&
    ruby bin/rails server webrick -e production -d -b 0.0.0.0" >> $LOG 2>&1
    date +"%T %a %d: redmine start end" >> $LOG 2>&1
    echo "redmine start end"
    touch /var/lock/subsys/redmine
    ;;
  stop)
    echo "redmine stop begin"
    date +"%T %a %d: redmine stop begin" >> $LOG 2>&1
    PID=`ps -ef | grep 'webrick' | grep -v grep | awk '{print $2}'`
    if [ ! -z "$PID" ]; then
      kill -15 $PID
    fi
    date +"%T %a %d: redmine start end" >> $LOG 2>&1
    echo "redmine stop end"
    rm -f /var/lock/subsys/redmine
    ;;
  restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "Usage: service redmine {start|stop|restart}"
    exit 1
  esac
  exit 0

chomod -R 777 redmine
service redmine start

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值