インストール方法

ここでの動作環境は次のとおり。

  • OS: FreeBSD 8-current
  • Webブラウザ: Firefox3.0.8

Redmineはビルド時にrakeを使うため、rakeが動作する環境が必要となる。FreeBSDの場合、ビルド前にあらかじめPortsから必要なアプリケーションをインストールしておく。

  • converters/ruby-iconv
  • databases/rubygems-sqlite3
  • devel/rubygem-rake
  • www/rubygem-rails

続いてRedmine本体をダウンロードする。のちのちのアップグレードを考えておくと、リポジトリからチェックアウトする方法が簡単で便利だろう。

% svn checkout http://redmine.rubyforge.org/svn/trunk/ ./redmine/

チェックアウト後、rakeをおこなう前にデータベースの準備をしておく。ここではSQLite3を採用した。チェックアウトしたディレクトリ以下の/config/database.yml.exampleをベースに、database.ymlを作成する。

% cd ./redmine/config
% cp database.yml.example database.yml
% vi database.yml

database.yml

production:
  adapter: sqlite3
  dbfile: db/redmine.db

データベースの環境をととのえたなら、いよいよrakeだ。次の3つのコマンドをチェックアウトしたディレクトリの直下で実行する。

% rake db:migrate RAILS_ENV="production"
% rake redmine:load_default_data RAILS_ENV="production"
% rake config/initializers/session_store.rb

rakeが無事に終了したら、動作しているかテストしてみよう。次のコマンドを実行し、Webブラウザでhttp://localhost:3000/にアクセスする。

% ruby script/server -e production

Redmineのトップページが表示された。ログインしていない場合は、Webブラウザの言語設定をもとにUIの言語が決定される

Apacheがすでにインストールされている環境の場合、Phusion Passengerを使って組み込んで使用する方法が便利だ。gem installでPhusion Passengerをインストールする。

# gem install passenger
# passenger-install-apache2-module

(省略)

The Apache 2 module was successfully installed.

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

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

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.

--------------------------------------------
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'!
   </VirtualHost>

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

  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.1/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.

インストール後に表示されるメッセージに従い、httpd.confとhttpd-vhosts.confに追記をおこなう。なお、ここではVirtualHostのPortに8080を指定している。

httpd.conf

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

httpd-vhosts.conf

Listen 8080
NameVirtualHost *:8080

<VirtualHost *:8080>

ServerName redmine.aquarius.localhost
DocumentRoot "/home/hiroaki/redmine/public"

<Directory />
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

</VirtualHost>

Apacheを再起動し、Webブラウザでhttp://localhost:8080/にアクセスする。

Apacheが起動していればRedmineにアクセスできる