2011/04/13

Xen DomUでRedmine + Phusion Passenger + Ruby Enterprise Edition

二年ぶりのご無沙汰でした。

Xen DomUで、Redmineを運用する。物理マシンの場合の手順は、『Redmine 1.1をCentOS5.5にインストールする手順』に詳しいが、Xen DomUにこれと同じ手順を適用すると、コンソールや/var/log/messagesあたりに次のようなメッセージが表示されることがある
4gb seg fixup, process ruby (pid 1270), cs:ip 73:00867ba6
4gb seg fixup, process ruby (pid 1270), cs:ip 73:001c30f1
4gb seg fixup, process ruby (pid 1270), cs:ip 73:00867ba6
4gb seg fixup, process ruby (pid 1270), cs:ip 73:001c30f1
printk: 96 messages suppressed.
4gb seg fixup, process ruby (pid 1270), cs:ip 73:00867ba6
これは、『4gb seg fixup REE XEN』で報告されている問題と同じで、ここで挙げられている通り、環境変数を設定してからRuby Enterprise Edition(以下、REE)をインストールすればよい。以下作業ログ。
REEをダウンロードし、展開する。
[fujino@DomU Ruby]$ ls ruby-enterprise-1.8.7-2011.03.tar.gz
ruby-enterprise-1.8.7-2011.03.tar.gz
[fujino@DomU Ruby]$ tar xzf ruby-enterprise-1.8.7-2011.03.tar.gz
[fujino@DomU Ruby]$
以下、rootで作業する。まず、環境変数を設定する。
[root@DomU Ruby]# export CFLAGS="-mno-tls-direct-seg-refs"
[root@DomU Ruby]# export CXXFLAGS="-mno-tls-direct-seg-refs"
[root@DomU Ruby]#
REEをインストールする。このとき、REEに同梱されているgemや開発者用ドキュメントをインストールしないよう指定する。
[root@DomU Ruby]# ./ruby-enterprise-1.8.7-2011.03/installer --dont-install-useful-gems --no-dev-docs
Welcome to the Ruby Enterprise Edition installer
This installer will help you install Ruby Enterprise Edition 1.8.7-2011.03.
Don't worry, none of your system files will be touched if you don't want them
to, so there is no risk that things will screw up.

You can expect this from the installation process:

1. Ruby Enterprise Edition will be compiled and optimized for speed for this
system.
2. Ruby on Rails will be installed for Ruby Enterprise Edition.
3. You will learn how to tell Phusion Passenger to use Ruby Enterprise
Edition instead of regular Ruby.

Press Enter to continue, or Ctrl-C to abort.[Enter]を入力

Checking for required software...

* C compiler... found at /usr/bin/gcc
* C++ compiler... found at /usr/bin/g++
* The 'make' tool... found at /usr/bin/make
* The 'patch' tool... found at /usr/bin/patch
* Zlib development headers... found
* OpenSSL development headers... found
* GNU Readline development headers... found
--------------------------------------------
Target directory

Where would you like to install Ruby Enterprise Edition to?
(All Ruby Enterprise Edition files will be put inside that directory.)

[/opt/ruby-enterprise-1.8.7-2011.03] :[Enter]を入力
--------------------------------------------
Compiling and optimizing the memory allocator for Ruby Enterprise Edition
In the mean time, feel free to grab a cup of coffee.

./configure --prefix=/opt/ruby-enterprise-1.8.7-2011.03 --disable-dependency-tracking
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
<<略>>
--------------------------------------------
Ruby Enterprise Edition is successfully installed!
If want to use Phusion Passenger (http://www.modrails.com) in combination
with Ruby Enterprise Edition, then you must reinstall Phusion Passenger against
Ruby Enterprise Edition, as follows:

/opt/ruby-enterprise-1.8.7-2011.03/bin/passenger-install-apache2-module

Make sure you don't forget to paste the Apache configuration directives that
the installer gives you.


If you ever want to uninstall Ruby Enterprise Edition, simply remove this
directory:

/opt/ruby-enterprise-1.8.7-2011.03

If you have any questions, feel free to visit our website:

http://www.rubyenterpriseedition.com

Enjoy Ruby Enterprise Edition, a product of Phusion (www.phusion.nl) :-)
[root@DomU Ruby]#
Gemを1.4.2へダウングレードする。
[root@DomU Ruby]# /opt/ruby-enterprise-1.8.7-2011.03/bin/ruby -S gem update --system 1.4.2
Updating rubygems-update
Fetching: rubygems-update-1.4.2.gem (100%)
Successfully installed rubygems-update-1.4.2
Installing RubyGems 1.4.2
RubyGems 1.4.2 installed
File not found: README
[root@DomU Ruby]# /opt/ruby-enterprise-1.8.7-2011.03/bin/ruby -S gem --version
1.4.2
[root@DomU Ruby]#
Rack 1.0.1およびi18n 0.4.2をインストールする。開発者用ドキュメントは不要なのでインストールしない。
[root@DomU Ruby]# /opt/ruby-enterprise-1.8.7-2011.03/bin/ruby -S gem install rack --version=1.0.1 --no-rdoc --no-ri
Fetching: rack-1.0.1.gem (100%)
Successfully installed rack-1.0.1
1 gem installed
[root@DomU Ruby]# /opt/ruby-enterprise-1.8.7-2011.03/bin/ruby -S gem install i18n --version=0.4.2 --no-rdoc --no-ri
Fetching: i18n-0.4.2.gem (100%)
Successfully installed i18n-0.4.2
1 gem installed
[root@DomU Ruby]#
づつけて、MySQL gemをインストールする。やはり開発者用ドキュメントは不要なのでインストールしない。
[root@DomU Ruby]# /opt/ruby-enterprise-1.8.7-2011.03/bin/ruby -S gem install mysql --no-rdoc --no-ri
Fetching: mysql-2.8.1.gem (100%)
Building native extensions. This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
[root@DomU Ruby]#
Apache HTTP Server用モジュールをインストールする。
[root@DomU Ruby]# /opt/ruby-enterprise-1.8.7-2011.03/bin/passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v3.0.6.

This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.

Here's what you can expect from the installation process:

1. The Apache 2 module will be installed for you.
2. You'll learn how to configure Apache.
3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.

Press Enter to continue, or Ctrl-C to abort.[Enter]を入力


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

Checking for required software...

* GNU C++ compiler... found at /usr/bin/g++
* Curl development headers with SSL support... found
* OpenSSL development headers... found
<<略>>

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

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

LoadModule passenger_module /opt/ruby-enterprise-1.8.7-2011.03/lib/ruby/gems/1.8/gems/passenger-3.0.6/ext/apache2/mod_passenger.so
PassengerRoot /opt/ruby-enterprise-1.8.7-2011.03/lib/ruby/gems/1.8/gems/passenger-3.0.6
PassengerRuby /opt/ruby-enterprise-1.8.7-2011.03/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.[Enter]を入力


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

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


ServerName www.yourhost.com
DocumentRoot /somewhere/public # <-- be sure to point to 'public'!

AllowOverride all # <-- relax Apache security settings
Options -MultiViews # <-- MultiViews must be turned off



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

/opt/ruby-enterprise-1.8.7-2011.03/lib/ruby/gems/1.8/gems/passenger-3.0.6/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.
[root@DomU Ruby]#