Home > Linux | Redmine | プロジェクト管理 > サクッとCentOS 5.4にRedmine + Passenger環境をインストール

サクッとCentOS 5.4にRedmine + Passenger環境をインストール このエントリーをはてなブックマークに追加 このエントリーを含むはてなブックマーク

shirotterです。

約1年前にサクッとCentOS 5.3にRedmine + Passenger環境をインストールを書きましたが、ちょうどインストールし直す機会があったので若干の変更をしながら書き直してみました。

前回の記事の改訂版のような扱いですが、下記の点で前回の内容と大きく異なります。

  1. Redmineのバージョンを0.8.3から0.9.3に変更
  2. DBをMySQLからPostgreSQLに変更
  3. Apacheの設定を若干変更

※ 重要でない標準出力などは前記事のものをそのまま流用しているので一部差異があるかもです。

Redmineのインストール手順

CentOSRedmine + PostgreSQL + Passenger環境をインストールする手順は下記のようになります。

  1. 事前の準備
  2. PostgreSQLのインストール
  3. Rubyのソースからのインストール
  4. Redmineのインストールと初期データの作成
  5. Passengerのインストールとapacheの設定

Redmineのインストール環境

今回のインストール環境は以下のようになっています。

OS CentOS 5.4 x86_64
DB PostgreSQL
HTTPサーバ apache + Passenger
Redmineのインストール先 /home/redmine

インストール開始

事前の準備

最初に必要となるモジュールをインストールしておきます。

# yum -y install gcc kernel-devel zlib-devel openssl-devel

PostgreSQLのインストール

# yum -y install postgresql-server postgresql-devel

※ 本記事ではPostgreSQLをそのままyumでインストールするように書いていますが、実際に作業を実施した環境では8.4を入れてから作業を行いました。特に設定などの違いは無いと思います。

PostgreSQLの設定の初期化と起動を行います。

# /etc/init.d/postgresql initdb
# /etc/init.d/postgresql start

ついでにOS起動時にPostgreSQLが起動されるようにも設定します。

# chkconfig postgresql on
# chkconfig --list postgresql
postgresql          0:off   1:off   2:on    3:on    4:on    5:on    6:off

ここからはPostgreSQLにRedmine用ユーザとDBを作成します。

// Redmine用ユーザを作成
# sudo -u postgres createuser -U postgres -dEeP
作成するロール名を入力してください: redmine
新しいロールのパスワード:
もう一度入力してください:
新しいロールをスーパーユーザとしますか?  (y/n)n
新しいロールにロールを作成する権限を与えますか? (y/n)n
CREATE ROLE redmine ENCRYPTED PASSWORD 'xxxxxxxx' NOSUPERUSER CREATEDB NOCREATEROLE INHERIT LOGIN;

// Redmine用DBを作成
# sudo -u postgres createdb -e -U postgres -O redmine redminedb "For redmine"
CREATE DATABASE redminedb OWNER redmine;
COMMENT ON DATABASE redminedb IS 'For redmine';

# sudo -u postgres psql"

// postgresユーザのパスワードを暗号化して設定
postgres=# alter user postgres with encrypted password 'xxxxxxxx';
ALTER ROLE

// 暗号化されたパスワードが保存されているか確認
postgres=# select * from pg_shadow;

 usename  | usesysid | usecreatedb | usesuper | usecatupd |       passwd        | valuntil | useconfig
----------+----------+-------------+----------+-----------+---------------------+----------+-----------
 redmine  |    16384 | t           | f        | f         | md5xxxxxxxxxxxxxxxx |          |
 postgres |       10 | t           | t        | t         | md5xxxxxxxxxxxxxxxx |          | 

postgres=# \q

さらにPostgreSQL本体の設定を若干変更しないといけません。

# vi /var/lib/pgsql/data/postgresql.conf

listen_addresses = '*'       <---- 追加。

# vi /var/lib/pgsql/data/pg_hba.conf

# "local" is for Unix domain socket connections only
local   all         all                               ident
# IPv4 local connections:
host    all         all         127.0.0.1/32          ident

を以下のように変更

# "local" is for Unix domain socket connections only
local   all         all                               md5
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5

これでPostgreSQLの設定は終わりました。

ここらで疲れてはいけません。
まだまだスタートラインに立ったばかりです。

Ruby のソースからのインストール

では本題に入っていきましょう。

まずは、
Rubyのインストールです。
最新版はここからURLを取得してください。

# wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p249.tar.gz
# tar xzvf ruby-1.8.7-p249.tar.gz
# cd ruby-1.8.7-p249
# ./configure --prefix=/usr
# make
# make test
test succeeded        <---- makeが成功しているか確かめます
# make install
# ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]

これでRubyはインストール出来ました。

次にRubyGemsのインストールです。
最新版はここからURLを取得してください。

# wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz
# tar xzvf rubygems-1.3.6.tgz
# cd rubygems-1.3.6
# ruby setup.rb
# gem -v
1.3.6

簡単ですね。
そして、Ruby on Railsのインストールとなります。

# gem update --system
# gem install rails --include-dependencies
# rails -v
Rails 2.3.5

Ruby関連のインストールは全て終わりました。

Redmineのインストール

いよいよRedmineの登場です。
僕は”/home/redmine”にインストールしますが、好みに合わせて変更してください。

# mkdir /home/redmine/
# wget http://rubyforge.org/frs/download.php/69449/redmine-0.9.3.tar.gz
# tar xzvf redmine-0.9.3.tar.gz
# cp -rp redmine-0.9.3/* /home/redmine/

RedmineのDB設定の変更
# cd /home/redmine/config
# cp -p database.yml.example database.yml
# vi database.yml

production:
  adapter: mysql
  database: redmine
  host: localhost
  username: root
  password:
  encoding: utf8

を以下のように変更

production:
  adapter: postgresql
  database: redminedb
  host: localhost
  username: redmine
  password: redmineユーザパスワード
  encoding: utf8
  scheme_search_path: public

クッキーに書き込まれるセッションデータの為のパスフレーズを設定
# cd /home/redmine/config/environment.rb
? 省略
Rails::Initializer.run do |config|
  config.action_controller.session = { :key => "_myapp_session", :secret => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }       30文字以上の文字列を追加します。
? 省略

pg gemのインストール
gem install pg

スキーマの作成
# rake db:migrate RAILS_ENV="production"

これでRedmineのインストールは終了です。

試しにRedmineを起動してアクセス出来るか試してみましょう。

# cd /home/redmine/
# script/server -e production
=> Booting WEBrick...
=> Rails 2.1.5 application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options

3000番ポートで起動されているので、
http://localhost:3000/ (ホスト名は適切なものに変更してください)
にブラウザからアクセスしてみます。

すると、

RedmineのTOPページ

RedmineのTOPページ

このような画面が表示されるはずです。

デフォルトでは、

ログイン : admin
パスワード : admin

でログイン出来ます。

ログイン出来たら、すでにRedmineを使うことが出来るようになっています。
(画像は日本語の画面になっていますが、デフォルトでは英語となっています。設定で言語を変更してください。)

Redmineを終了するには「Ctrl + C」キーを押します。

Passengerのインストールとapacheの設定

これで一通りの作業は終わりましたが、いちいち3000番ポートにアクセスしないといけないのは嫌なので、apache上で動くように設定することにします。

apache上で動くようにするにはPassengerと連携させることになります。

ではPassengerのインストールを行います。
まずは必要となるものをインストールします。

# yum -y install httpd-devel gcc-c++ apr-devel

Passengerをインストールします。
# gem install passenger
# passenger-install-apache2-module

Press Enter to continue, or Ctrl-C to abort.
と言われるのでEnterを押して続行します。

すると、

--------------------------------------------

Checking for required software...

 * GNU C++ compiler... found at /usr/bin/g++
 * Ruby development headers... found
 * OpenSSL support for Ruby... found
 * RubyGems... found
 * Rake... found at /usr/bin/rake
 * Apache 2... found at /usr/sbin/httpd
 * Apache 2 development headers... found at /usr/sbin/apxs
 * fastthread... found
 * Apache Portable Runtime (APR) development headers... found at /usr/bin/apr-1-config
 * Apache Portable Runtime Utility (APU) development headers... found at /usr/bin/apu-1-config

--------------------------------------------

というようなものが表示されます。

これは必要なモジュールが揃っている状態の表示ですが、何か1つでもモジュールが不足しているとこの画面で怒られてしまいます。
(必要なモジュールのインストール方法を後で教えてくれますが・・・)

--------------------------------------------
The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
   PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11
   PassengerRuby /usr/bin/ruby

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!

Press ENTER to continue.

こんな画面が表示されて一端止まります。

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11
PassengerRuby /usr/bin/ruby

の部分は後で必要になってくるので、
どこかにメモを取っておく必要があります。

メモを取ったらEnter

--------------------------------------------
Deploying a Ruby on Rails application: an example

Suppose you have a Ruby on Rails application in /somewhere. Add a virtual host
to your Apache configuration file, and set its DocumentRoot to
/somewhere/public, like this:

   <VirtualHost *:80>
      ServerName www.yourhost.com
      DocumentRoot /somewhere/public    # <-- be sure to point to 'public'!
      <Directory /somewhere/public>
         AllowOverride all              # <-- relax Apache security settings
         Options -MultiViews            # <-- MultiViews must be turned off
      </Directory>
   </VirtualHost>

And that's it! You may also want to check the Users Guide for security and
optimization tips and other useful information:

  /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/doc/Users guide Apache.html

Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-) 

http://www.modrails.com/

Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.

そして、こんな表示になって終了します。

ここでも

<VirtualHost *:80>
ServerName www.yourhost.com
DocumentRoot /somewhere/public # <– be sure to point to ‘public’!
<Directory /somewhere/public>
AllowOverride all # <– relax Apache security settings
Options -MultiViews # <– MultiViews must be turned off
</Directory>
</VirtualHost>

の部分をメモに取っておきましょう。

メモを取った内容を参考にapacheの設定を行います。

まずはpassenger用の設定ファイルを用意します。

# cd /etc/httpd/conf.d/
新規にconfファイルを作成
# vi passenger.conf
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11
PassengerRuby /usr/bin/ruby

次にhttpd.confの設定です。

# cd /etc/httpd/conf
# vi httpd.conf
以下を追加

<VirtualHost *:80>
   ServerName www.example.com
   DocumentRoot /var/www/html
   RailsBaseURI /redmine
   ErrorLog /var/log/httpd/redmine_error.log                  <---- エラーログ出力先を変更
   CustomLog /var/log/httpd/redmine_access.log combined       <---- アクセスログ出力先を変更
   <Directory /var/www/html>
      AllowOverride all
      Options -MultiViews
   </Directory>
</VirtualHost>

// Apacheの設定に問題が無いか確認
# /etc/init.d/httpd configtest
Syntax OK

Redmineのルートディレクトリへのシンボリックリンクを”/var/www/html”に作成します。

# cd /var/www/html/
# ln -s /home/redmine/public/ redmine

Apacheがシステムの起動時に自動起動するように設定します。

# chkconfig httpd on
# chkconfig --list httpd
httpd          0:off   1:off   2:on    3:on    4:on    5:on    6:off

残るはRedmineのファイルのパーミッションの設定のみです。

# chown -R apache:apache /home/redmine

あとはapacheを起動してみましょう。

# /etc/rc.d/init.d/httpd start

これで、
http://(httpd.confに入れたホスト名)/redmine/
にアクセスすればRedmineに繋がるはずです。

Redmineのインストール作業は以上となります。

前回の記事の焼き直しですが、困っている方の参考になれば・・・

使用したソフトウェアのバージョン

CentOS 5.4 x86_64
PostgreSQL 8.4.3
Ruby 1.8.7-p-249
RubyGems 1.3.6
Ruby on Rails 2.3.5
Redmine 0.9.3
apache 2.2.3-31
Passenger 2.2.11
Redmine -もっと手軽にプロジェクト管理!
倉貫 義人 栗栖 義臣 並河 祐貴 前田 直樹
インプレスジャパン
売り上げランキング: 27472
おすすめ度の平均: 2.5

3 インストールには役に立たなかった。
2 読まなくてもわかる
3 Windowsでサーバの構築

Comments:0

Comment Form
Remember personal info

コメントリンクを nofollow free に設定することも出来ます。

Trackbacks:1

Trackback URL for this entry
http://www.sakuttoly.com/blog/2010/04/redmine93_passenger_centos54.html/trackback
Listed below are links to weblogs that reference
サクッとCentOS 5.4にRedmine + Passenger環境をインストール from サクっとly.com
trackback from hiromasa.another :o) 10-08-01 (日) 5:18

プロジェクト管理アプリケーション Redmine

気になっていました、プロジェクト管理アプリケーション Redmine を入れてみました。 実は shiroica さんが以前から使われているようだったので、それを見てすぐに試してみたかったのです…

Home > Linux | Redmine | プロジェクト管理 > サクッとCentOS 5.4にRedmine + Passenger環境をインストール

ページ
アーカイブ
商品を検索
kubomaのオススメ書籍
メタ情報

Return to page top