5/10/2011

Deploy redmine to Tomcat 6

目前已經有現存Apache Tomcat 架構,不太想用mongrel或passenger來設定管理,可簡易透過Jruby跑redmine服務在tomcat server。

隨手寫下備忘錄

準備環境 (ubuntu 11 )

[code lang="bash"] sudo apt-get install jruby [/code]

gem安裝package

[code lang="bash"] ( 目前僅支援 rails 2.3.5) jruby -S gem install rails -v=2.3.5 ( 將redmine包成war檔) jruby -S gem install warbler jruby -S gem install activerecord-jdbc-adapter jruby -S gem install jdbc-mysql jruby -S gem install activerecord-jdbcmysql-adapter [/code]

抓下redmine 1.2 版本

[code lang="bash"] svn co http://redmine.rubyforge.org/svn/tags/1.1.2/ [/code]

新增redmine資料庫

[code lang="bash"] create database redmine character set utf8; grant all privileges on redmine.* to 'redmine'@'localhost' identified by 'redmine'; [/code]

修改資料庫設定

[code lang="bash"] vim config/database.yml production: adapter: jdbcmysql database: redmine host: localhost username: redmine password: redmine encoding: utf8 [/code]

修改設定

[code lang="bash"] vim config/environment.rb ... begin require File.join(File.dirname(__FILE__), '../vendor/plugins/engines/boot') rescue LoadError # Not available end #新增 if Gem::VERSION >= "1.3.6" module Rails class GemDependency def requirement r = super (r == Gem::Requirement.default) ? nil : r end end end end Rails::Initializer.run do |config| ... [/code]

redmine 目錄執行資料建立

[code lang="bash"] jruby -S rake generate_session_store jruby -S rake db:migrate RAILS_ENV=production jruby -S rake load_default_data RAILS_ENV=production [/code]

只少在ruby環境確認沒有問題

[code lang="bash"] jruby script/server -e production [/code]

修改production環境log(針對tomcat)

[code lang="bash"] vi config/environments/production.rb config.logger = Logger.new(config.log_path) config.logger.level = Logger::INFO [/code]

warable產生設定檔

[code lang="bash"] jruby -S warble config [/code]

根據需求調整

[code lang="bash"] (使用預設) vim config/warble.rb [/code]

包成war檔

[code lang="bash"] jruby -S warble [/code]

Tomcat配置 (根據Tomcat環境設定)

[code lang="bash"] mv redmine-1.1.2.war /usr/local/tomcat/webapps/redmine.war /usr/local/tomcat/bin/startup.sh [/code]

測試

http://localhost:8080/redmine/

參考

http://www.redmine.org/projects/redmine/wiki/HowTo_install_Redmine_in_Apache_Tomcat

測試結果速度非常理想,雖然沒有實際好好測過 。另外一提Jruby讓我非常期待它的發展 (cool) !

No comments:

Post a Comment