Redmine

提供: 個人的記録
2016年8月22日 (月) 14:40時点におけるGonbe (トーク | 投稿記録)による版

移動: 案内検索

インストール

パッケージインストール

パッケージをインストールする。めんどくさいのでpkgでさくっといれる。

pkg install redmine
pkg install rubygem-unicorn
pkg install nginx

redmineの設定

データベースの設定

firebirdは使えなかったので、とりあえず、sqliteで使用する。
データーベースの設定ファイル /usr/local/www/redmine/config/database.yml に以下の内容を記述する。

production:
   adapter: salite3
   database: db/redmine.sqlite
   encoding: utf8
 
development:
  adapter: sqlite3
  database: db/redmine_dev.sqlite

秘密鍵の作成と初期データの投入

Redmineのディレクトリ(/usr/local/www/redmine)で作業を行う。
秘密鍵の作成

rake generate_secret_token

DBの初期化

sh
RAILS_ENV=production rake db:migrate
RAILS_ENV=production REDMINE_LANG=ja rake redmine:load_default_data

データ配置フォルダの作成

mkdir -p tmp tmp/pdf public/plugin_assets
chown -R www:www files log tmp public/plugin_assets
chmod -R 755 files log tmp public/plugin_assets

稼働確認

webrickで稼働確認をする。以下のコマンドを実行し、稼働させたうえでブラウザでアクセスする。 -b オプションを抜かすとループバックアドレスにbindされてしまい、外部からブラウザで確認できないので注意。

ruby bin/rails server webrick -e production  -b 0.0.0.0

unicornの設定

nginx連携のために、unicornの起動スクリプトを記述する。
ファイルは /usr/local/www/redmine/config/unicorn.rb とする。

@dir = "/usr/local/www/redmine"
worker_processes 1
working_directory @dir

#nginxに渡すソケットの設定。wwwの下に置くものではないので/varに
listen "/var/run/unicorn.sock"
pid "/var/run/unicorn.pid"

preload_app true

stdout_path File.expand_path("log/unicorn.stdout.log", @dir)
stderr_path File.expand_path("log/unicorn.stderr.log", @dir)

= サブディレクトリの設定

redmineをトップレベルで動かす気はないので、サブディレクトリで動くようにする。
/usr/local/www/redmine/config.ru を以下のように書き換える。

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  __FILE__)

# もともとの設定。トップレベルでの起動になる。
#run RedmineApp::Application

# 環境変数であたえられたディレクトリごとに起動するようにする。
if ENV['RAILS_RELATIVE_URL_ROOT']
 map ENV['RAILS_RELATIVE_URL_ROOT'] do
    run RedmineApp::Application
 end
else
 run RedmineApp::Application
end

unicornの起動

以下のコマンドでunicornをデーモンで起動する。--path で指定したパスがrailsのルートフォルダになる。

unicorn_rails -c config/unicorn.rb -E production -D --path /redmine

止める場合は

kill -9 `cat /var/run/unicorn.pid`

nginxの設定

/usr/local/etc/nginx/nginx.conf がnginxの設定ファイル。
httpブロックに以下の内容を追加し、unicornのソケットと連携できるようにする。

upstream redmine{
   server unix:/var/run/unicorn.sock;
}
<pre>
ここで指定するパスはunicornの設定で作ったsockファイルを指定する。