| LFSトップ | Japanese Only | 2010/01/26 |
RedMine-0.9.0
はじめに
- Ruby On Rails により構築されている、フリーのプロジェクト管理ソフトウェア「RedMine」を導入する。
- 種々の利用ソフトウェアとして以下を用いるものとする。
- データベースに MySQL
- Webサーバーとして、フロントに Apache、バックに Mongrel_Cluster
- FastCGI も導入。
- GUI は不要なので X ウィンドウシステム (Xorg) は導入しない。
- RedMine 実行ユーザーは「rails」を新規作成、DBアクセスユーザーは「redmine」とする。ユーザーは何でもよい。
- RedMine のソースは、rails ユーザーのホームディレクトリ配下、/home/rails/sites/redmine に置く。
- システム構築を優先する。セキュリティへの配慮は二の次とする。(なぜかと言えば、実は十分に理解していないから・・・)
参考リンク
依存環境、パッケージ
依存パッケージ類の導入
railsユーザーの新規作成
- rails ユーザーを新規作成する。グループは apache とする。rails のパスワードも設定する。
- Apache のグループ名は既存ディストリビューションでは www-data としているものもある。BLFS では apache。
Apacheの導入時に生成済。
[rootユーザー]
useradd -m -s /bin/bash -g apache rails
passwd rails
rails のパスワードを変更しています
新しいパスワードを入れてください (最短 5 文字)
大文字・小文字・数字を混ぜて使うようにしてください。
新しいパスワード: XXXXX
不正なパスワードです: 単純すぎます
警告: 弱いパスワードです (どうしてもこれを使いたければもう一度入力)。
新しいパスワード: XXXXX
新規パスワード再入力: XXXXX
passwd: password changed.
ソース配置
- RedMine のソースを rails ユーザーのホームディレクトリ配下に配置する。
[railsユーザー]
mkdir ~/sites
cd ~/sites
tar xf <downloadpath>/redmine-0.9.0.tar.gz
- 「redmine-0.9.0」ディレクトリをシンボリックリンクにより「redmine」とする。
[railsユーザー]
cd ~/sites
ln -sv redmine-0.9.0 redmine
`redmine' -> `redmine-0.9.0'
- 最新ソース(svn)を投入したい場合は、Subversion を導入の上、「cd ~/sites && svn co http://redmine.rubyforge.org/svn/trunk redmine」としても良い。ただし Subversion ソースツリーをそのまま Web 公開ディレクトリとすることは多分ご法度のはず(?) 適宜対応要。
RedMine のDB構築
- MySQL に対して RedMine のDBを構築する。まずは MySQL に接続する。
[railsユーザー]
mysql -u root -p
Enter password: XXXXX
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.42-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
- MySQL プロンプトにて以下の太字部分の入力によりDBを生成する。最後は \q により終了する。RedMine のインストール手順そのまま。
- これは production 環境のみを生成するものである。development 環境や test 環境を必要とする場合は、同等の create 文を要する。ここでは生成しない。
mysql> create database redmine character set utf8;
Query OK, 1 row affected (0.00 sec)
mysql> create user 'redmine'@'localhost' identified by 'redmine';
Query OK, 0 rows affected (0.05 sec)
mysql> grant all privileges on redmine.* to 'redmine'@'localhost';
Query OK, 0 rows affected (0.05 sec)
mysql> \q
Bye
RedMine のDB設定
- RedMine のDB接続設定を行う。
- まず初めにDB設定サンプルファイル config/database.yml.example をコピーして config/database.yml とする。
- 幸いサンプルファイルは MySQL 用となっているので、そのまま流用し、最低限必要箇所のみ書き換えればよい。(後続手順にて)
[railsユーザー]
cd ~/sites/redmine
cp config/database.yml.example config/database.yml
- そして config/database.yml 内にてDB接続ユーザーを redmine として設定する。
- production 環境用の設定(production: の項部分)さえすれば十分。とりあえず development とかも同様としておく。
[railsユーザー]
vi config/database.yml
...
production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: redmine
encoding: utf8
development:
adapter: mysql
database: redmine_development
host: localhost
username: redmine
password: redmine
encoding: utf8
test:
adapter: mysql
database: redmine_test
host: localhost
username: redmine
password: redmine
encoding: utf8
...
- config/environment.rb を編集し、暗号化キー文字列を設定する。
- 以下の太字部分を追記し、":secret =>" の先に定める文字列として、30文字以上の任意の文字列を設定する。
[railsユーザー]
cd ~/sites/redmine
vi config/environment.rb
...
# Enable page/fragment caching by setting a file-based store
# (remember to create the caching directory and make it readable to the application)
# config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache"
config.action_controller.session =
{ :key => "_myapp_session", :secret => "This is test key for RedMine site" }
...
RedMine のDB定義投入
- RedMine のDBテーブル群を投入する。数々のテーブル定義の投入メッセージが表示される。RedMine のインストール手順そのまま。
[railsユーザー]
cd ~/sites/redmine
rake db:migrate RAILS_ENV=production
== Setup: migrating ==========================================================
-- create_table("attachments", {:force=>true})
-> 0.0420s
-- create_table("auth_sources", {:force=>true})
-> 0.0626s
-- create_table("custom_fields", {:force=>true})
-> 0.0226s
-- create_table("custom_fields_projects", {:force=>true, :id=>false})
-> 0.0257s
...
== ChangeWikiContentsTextLimit: migrating ====================================
-- change_column(:wiki_contents, :text, :text, {:limit=>16777216})
-> 0.0957s
-- change_column(:wiki_content_versions, :data, :binary, {:limit=>16777216})
-> 0.0764s
== ChangeWikiContentsTextLimit: migrated (0.1732s) ===========================
- RedMine の初期データ群を投入する。途中、言語選択を必要とするので「ja」(日本語)を入力する。
[railsユーザー]
rake load_default_data RAILS_ENV=production
(in /home/rails/sites/redmine-0.9.0)
Select language: bg, bs, ca, cs, da, de, el, en, es, fi, fr, gl, he, hu, id, it, ja, ko, l
t, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sr, sv, th, tr, uk, vi, zh, zh-TW [en] ja
====================================
Default configuration data loaded.
Note: The rake task load_default_data has been deprecated, please use the replacement vers
ion redmine:load_default_data
Mongrel Cluster の設定
- Mongrel Cluster の設定を行う。
- HTTPポートは 4000 から3つ(4000,4001,4002)を用いるものとする。
- RedMine の環境は production 環境を利用。PID は /var/run/mongrel-cluster に配置。
(本サイトメモ:Mongrel-cluster にて生成済。)
[railsユーザー]
cd ~/sites/redmine
mongrel_rails cluster::configure \
-e production \
-p 4000 \
-a 0.0.0.0 \
-l /home/rails/sites/redmine/log/mongrel_cluster.log \
-P /var/run/mongrel_cluster/redmine.pid \
-c /home/rails/sites/redmine \
-r /home/rails/sites/redmine/public \
-N 3 \
--user rails \
--group apache
Writing configuration file to config/mongrel_cluster.yml.
- Mongrel cluster のサービススクリプトの設定ディレクトリ(本サイトメモ:Mongrel-cluster にて生成済)
において、上で生成された config/mongrel_cluster.yml ファイルを、redmine.yml という名でシンボリックリンクを張る。
[rootユーザー]
cd /etc/mongrel_cluster
ln -s /home/rails/sites/redmine/config/mongrel_cluster.yml redmine.yml
- Mongrel cluster のサービスをこの時点で(再)起動し、設定に問題がないかを確認する。
[rootユーザー]
/etc/rc.d/init.d/mongrel-cluster restart
Restarting all mongrel_clusters... [ OK ]
- Mongrel cluster のプロセスを確認しておく。ポート 4000, 4001, 4002 にて mongrel_rails が問題なく起動。
[rootユーザー]
ps -ef | grep mongrel
rails 30398 1 31 20:46 ? 00:00:02 /usr/bin/ruby /usr/bin/mongrel_rails start
-d -e production -a 0.0.0.0 -c /home/rails/sites/redmine -r /home/rails/sites/redmine/pub
lic --user rails --group apache -p 4000 -P /var/run/mongrel_cluster/redmine.4000.pid -l /h
ome/rails/sites/redmine/log/mongrel_cluster.4000.log
rails 30401 1 27 20:46 ? 00:00:01 /usr/bin/ruby /usr/bin/mongrel_rails start
-d -e production -a 0.0.0.0 -c /home/rails/sites/redmine -r /home/rails/sites/redmine/pub
lic --user rails --group apache -p 4001 -P /var/run/mongrel_cluster/redmine.4001.pid -l /h
ome/rails/sites/redmine/log/mongrel_cluster.4001.log
rails 30404 1 28 20:47 ? 00:00:01 /usr/bin/ruby /usr/bin/mongrel_rails start
-d -e production -a 0.0.0.0 -c /home/rails/sites/redmine -r /home/rails/sites/redmine/pub
lic --user rails --group apache -p 4002 -P /var/run/mongrel_cluster/redmine.4002.pid -l /h
ome/rails/sites/redmine/log/mongrel_cluster.4002.log
root 30410 14987 0 20:47 pts/3 00:00:00 grep mongrel
Apache のプロキシ設定
- Apache のプロキシ設定を行う。
- まずはプロキシ設定を行うファイル httpd-proxy.conf ファイルを新規生成する。
- images, javascripts, stylesheets の各静的ファイル類は、Mongrel に委ねず Apache が対応することに。
それを設定するのが ProxyPass /redmine/images/ ! などの行。
[rootユーザー]
cd /etc/apache/extra
cat > httpd-proxy.conf << "EOF"
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /redmine/images/ !
ProxyPass /redmine/javascripts/ !
ProxyPass /redmine/stylesheets/ !
ProxyPass /redmine balancer://redmine lbmethod=byrequests timeout=1
ProxyPassReverse /redmine balancer://redmine
<Proxy balancer://redmine>
BalancerMember http://localhost:4000 loadfactor=10
BalancerMember http://localhost:4001 loadfactor=10
BalancerMember http://localhost:4002 loadfactor=10
</Proxy>
EOF
- Apache 全体の設定ファイル httpd.conf から、上のファイルを読み込むようにする。
[rootユーザー]
vi /etc/apache/httpd.conf
...
Include /etc/apache/extra/httpd-proxy.conf
...
- Apache のデフォルトの Web ページ置き場 htdocs 内に、RedMine の images, javascripts, stylesheets ディレクトリへのシンボリックリンクを生成する。これらの静的コンテンツは Mongrel 経由とはせずに、Apache が処理するようにする。
- ただしシンボリックリンクはセキュリティ上、まずい気がして仕方ない・・・ 他の方の様子見としておこう。
[rootユーザー]
cd /srv/www/htdocs
mkdir -pv redmine
cd redmine
ln -sv /home/rails/sites/redmine/public/{images,javascripts,stylesheets} .
`./images' -> `/home/rails/sites/redmine/public/images'
`./javascripts' -> `/home/rails/sites/redmine/public/javascripts'
`./stylesheets' -> `/home/rails/sites/redmine/public/stylesheets'
[rootユーザー]
/etc/rc.d/init.d/apache restart
Restarting Apache daemon... [ OK ]
RedMine のルート設定
- config/environment.rb にて相対ディレクトリ設定。
[railsユーザー]
cd ~/sites/redmine
vi config/environment.rb
...
config.action_controller.relative_url_root = '/redmine'
...
RedMine 操作
- Webブラウザより http://<サーバー名>/redmine でアクセス。
- 以下では Windows XP クライアントから、Internet Explorer 6.0 でアクセスした例。
- 実は Internet Explorer 6.0 ではログイン出来ないエラー。Invalid form authenticity token.
- 調べるのが面倒。どのみち Internet Explorer は私にとってデフォルトブラウザではないから。
- 気を取り直して Firefox でアクセス。
|
|
| 松 山 道 夫 Michio Matsuyama |
|