UbuntuにRedmineをインストール

環境

OS
Ubuntu10.10
Redmine
1.2.0(ちょうど2011/05/30に出ていたようなので)
DB
PostgreSQL8.4.8

インストール手順

ダウンロード

RubyForge: Redmine: Project Filelistからダウンロードします。
ダウンロードしたファイルを展開します。

$ cd /tmp
$ wget http://rubyforge.org/frs/download.php/74944/redmine-1.2.0.tar.gz
$ tar xzvf redmine-1.2.0.tar.gz
$ sudo mv redmine-1.2.0 /usr/local/redmine
データベースユーザ作成

postgresユーザで作業します。

$ su - postgres
$ psql
postgres=# CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'redmine' NOINHERIT VALID UNTIL 'infinity';
postgres=# CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine;
postgres=# \q
config/database.yml作成
$ cd /usr/local/redmine
$ cp config/database.yml.example config/database.yml
$ vim config/database.yml
〜〜省略〜〜
  3 production:
  4   adapter: postgresql
  5   database: redmine
  6   host: localhost
  7   username: redmine
  8   password: redmine
  9   encoding: utf8
 10   schema_search_path: public
〜〜省略〜〜
config/environment.rb修正
$ vim config/environment.rb
config.action_controller.session = { :key => "_myapp_session", :secret => "n74xmaiwiy9o5gj1iggpp76i6gs535c" }
テーブル作成
$ cd /usr/local/redmine
$ rake db:migrate RAILS_ENV=production

※はじめrakeでこけるので、以下のGemをインストールしました。

$ gem install -v=0.4.2 i18n
$ gem install -v=1.1.0 rack
初期データ登録
$ rake redmine:load_default_data RAILS_ENV=production
(in /usr/local/redmine)

Select language: bg, bs, ca, cs, da, de, el, en, en-GB, es, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] ja
====================================
Default configuration data loaded.
確認
$ ruby script/server webrick -e production
=> Booting WEBrick
=> Rails 2.3.11 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-06-02 13:03:15] INFO  WEBrick 1.3.1
[2011-06-02 13:03:15] INFO  ruby 1.8.7 (2011-02-18) [i686-linux]
[2011-06-02 13:03:21] INFO  WEBrick::HTTPServer#start: pid=3922 port=3000

http://ホスト:3000/にアクセスして確認。

Passenger設定

複数のRailsアプリを動かせるようにします。

/etc/apache2/sites-available/default修正
$ sudo vim /etc/apache2/sites-available/default
  1 <VirtualHost *:80>
  2         ServerAdmin webmaster@localhost
  3
  4         DocumentRoot /var/www
  5         RailsEnv development
  6         RailsBaseURI /rails3
  7         RailsBaseURI /redmine
  8         <Directory />
  9                 Options FollowSymLinks
 10                 AllowOverride None
 11         </Directory>
 12         <Directory /var/www>
 13 #               Options Indexes FollowSymLinks MultiViews
 14 #               AllowOverride None
 15 #               Order allow,deny
 16 #               allow from all
 17          AllowOverride all
 18          Options -MultiViews
 19         </Directory>
 20
 21         ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
 22         <Directory "/usr/lib/cgi-bin">
 23                 AllowOverride None
 24                 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
 25                 Order allow,deny
 26                 Allow from all
 27         </Directory>
 28
 29         ErrorLog ${APACHE_LOG_DIR}/error.log
 30
 31         # Possible values include: debug, info, notice, warn, error, crit,
 32         # alert, emerg.
 33         LogLevel warn
 34
 35         CustomLog ${APACHE_LOG_DIR}/access.log combined
 36
 37     Alias /doc/ "/usr/share/doc/"
 38     <Directory "/usr/share/doc/">
 39         Options Indexes MultiViews FollowSymLinks
 40         AllowOverride None
 41         Order deny,allow
 42         Deny from all
 43         Allow from 127.0.0.0/255.0.0.0 ::1/128
 44     </Directory>
 45
 46 </VirtualHost>
  • 6行目と7行目にアプリを指定
シンボリックリンク設定

上記で設定したDocumentRoot(/var/www)から指定した名前でアプリにシンボリックリンクを設定します。

$ cd /var/www
$ ln -s /home/atsm/workspaces/rails3/public rails3
$ ln -s /usr/local/redmine/public redmine
実行時の環境を指定

デフォルトはRailsEnv development のとおり、development。
redmineのほうだけ、productionで実行します。

$ cd /usr/local/redmine
$ vim config/environment.rb
〜〜省略〜〜
  3 # Uncomment below to force Rails into production mode when
  4 # you don't control web/app server and can't set it the proper way
  5 ENV['RAILS_ENV'] = 'production'
  6
  7 # Specifies gem version of Rails to use when vendor/rails is not present
〜〜省略〜〜
  • 5行目をコメントをはずして、|| をとった。