redmineのバージョンアップ
redmineが2系でそろそろ古いかなと思って、バージョンアップしてみたのでメモ。
あと、ubuntu14.04だとrubyが1.9系で微妙なので、それもアップデートした。
バックアップ
redmineのディレクトリは念のため、まるっとバックアップしておく。
$ cp -rp /path/to/redmine /path/to/backup/
DBのダンプ
$ mysqldump -u redmine -p | gzip -c > /path/to/backup/redmine.backup.gz
rubyのインストール
$ wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.4.tar.gz $ tar zxvf ruby-2.3.4.tar.gz $ cd ruby-2.3.4 $ ./configure --disable-install-doc --prefix=/path/to/ruby2.3.4 $ make $ sudo make install
bundlerのインストール
$ sudo /path/to/ruby2.3.4/bin/gem install bundler
redmineのインストール
redmineをダウンロードして解凍
$ rm -fr /path/to/redmine $ wget http://www.redmine.org/releases/redmine-3.3.3.tar.gz $ tar zxvf redmine-3.3.3.tar.gz $ sudo mv redmine-3.3.3 /path/to/redmine
旧環境から設定をコピー
$ sudo cp /path/to/backup/redmine/config/database.yml /path/to/redmine/config/ $ sudo cp /path/to/backup/redmine/config/configuration.yml /path/to/redmine/config/
$ chown -R redmine:redmine /path/to/redmine
依存モジュールのインストール。
まず、アプリケーションサーバにthinを利用しているのでGemfileにthinを追加
gem 'thin'
その後bundle install
$ cd /path/to/redmine $ sudo -H -u redmine /path/to/ruby2.3.4/bin/bundle install --path vendor/bundle --without development test rmagick
セキュリティトークンの作成
$ sudo -H -u redmine /path/to/ruby2.3.4/bin/bundle exec rake generate_secret_token
DBの更新
$ sudo -H -u redmine /path/to/ruby2.3.4/bin/bundle exec rake db:migrate RAILS_ENV=production
セッションやキャッシュの削除
$ sudo -H -u redmine /path/to/ruby2.3.4/bin/bundle exec rake tmp:cache:clear tmp:sessions:clear RAILS_ENV=production
thinの設定を作成。/path/to/redmine/config/thin.ymlに保存する。
chdir: /path/to/redmine environment: production address: 127.0.0.1 port: 3000 timeout: 30 log: log/thin.log pid: tmp/pids/thin.pid max_conns: 1024 max_persistent_conns: 512 require: [] wait: 30 daemonize: true prefix: /redmine user: redmine group: redmine
thinの起動
$ cd /path/to/redmine $ sudo -H -u redmine RAILS_RELATIVE_URL_ROOT=/redmine /path/to/ruby2.3.4/bin/bundle exec thin start -C /path/to/redmine/config/thin.yml
RAILS_RELATIVE_URL_ROOTはredmineをサブurl(/redmine)でアクセスしているのでそうしている。
apache側は3000ポートにproxyしているだけ
<Location /redmine> ProxyPass http://localhost:3000/redmine ProxyPassReverse http://localhost:3000/redmine </Location>
あとはデーモン化するとか残っているけどとりあえずここまで。