ラベル RoR の投稿を表示しています。 すべての投稿を表示
ラベル RoR の投稿を表示しています。 すべての投稿を表示

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]#

2008/07/15

Ruby on Rails 2.1 on CentOS 5.2・その3・Gemパッケージのインストール

RoRをインストールする。RoRはGemパッケージとして提供されている。インストールには、gemコマンドを使用する。
# gem install rails --include-dependencies
INFO:  `gem install -y` is now default and will be removed
INFO:  use --ignore-dependencies to install only the gems you list
Successfully installed rake-0.8.1
Successfully installed activesupport-2.1.0
Successfully installed activerecord-2.1.0
Successfully installed actionpack-2.1.0
Successfully installed actionmailer-2.1.0
Successfully installed activeresource-2.1.0
Successfully installed rails-2.1.0
7 gems installed
Installing ri documentation for rake-0.8.1...
Installing ri documentation for activesupport-2.1.0...
Installing ri documentation for activerecord-2.1.0...
Installing ri documentation for actionpack-2.1.0...
Installing ri documentation for actionmailer-2.1.0...
Installing ri documentation for activeresource-2.1.0...
Installing RDoc documentation for rake-0.8.1...
Installing RDoc documentation for activesupport-2.1.0...
Installing RDoc documentation for activerecord-2.1.0...
Installing RDoc documentation for actionpack-2.1.0...
Installing RDoc documentation for actionmailer-2.1.0...
Installing RDoc documentation for activeresource-2.1.0...
#
RoR 2.1では、標準のデータベースとして、SQLite3を使用するので、Gemパッケージsqlite3-rubyも併せてインストールした方が良い。
# gem install sqlite3-ruby
Building native extensions.  This could take a while...
Successfully installed sqlite3-ruby-1.2.2
1 gem installed
Installing ri documentation for sqlite3-ruby-1.2.2...
Installing RDoc documentation for sqlite3-ruby-1.2.2...
#
これでインストールは終了のはずなのだが、このままだとRoRが正しく動作しない。例えば、『チュートリアルステップ6』でhttp://RAILS/friends/viewを表示させると、ブラウザにエラー画面が表示される。


次のエラーメッセージが表示されている。
no such file to load -- sqlite3/database
これは、Gemパッケージsqlite3-rubyのパーミッションが間違っているためだ。確認し、修正する。
# cd /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.2
# find . -perm 0662
./doc/faq/faq.rb
./ext/sqlite3_api/extconf.rb
./ext/sqlite3_api/sqlite3_api.i
./lib/sqlite3/database.rb
./lib/sqlite3/translator.rb
./test/tc_errors.rb
./test/tc_integration.rb
# ls -l lib/sqlite3/
total 116
-rw-r--r-- 1 root root  1745 Jul 15 17:38 constants.rb
-rw-rw--w- 1 root root 24774 Jul 15 17:38 database.rb
drwxr-xr-x 4 root root  4096 Jul 15 17:38 driver
-rw-r--r-- 1 root root  2307 Jul 15 17:38 errors.rb
-rw-r--r-- 1 root root  7480 Jul 15 17:38 pragmas.rb
-rw-r--r-- 1 root root  4690 Jul 15 17:38 resultset.rb
-rw-r--r-- 1 root root  6843 Jul 15 17:38 statement.rb
-rw-rw--w- 1 root root  3738 Jul 15 17:38 translator.rb
-rw-r--r-- 1 root root  1057 Jul 15 17:38 value.rb
-rw-r--r-- 1 root root   153 Jul 15 17:38 version.rb
# chmod 644 `find . -perm 0662`
#

その0・概要
その1・RubyのRPMパッケージのビルドとインストール
その2・RubyGemsのインストール
その3・Gemパッケージのインストール

Ruby on Rails 2.1 on CentOS 5.2・その2・RubyGemsのインストール

RubyGemsをダウンロードする。
$ mkdir -p Src/Ruby
$ cd Src/Ruby
$ wget http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz
--23:47:10--  http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz
Resolving rubyforge.org... 205.234.109.19
Connecting to rubyforge.org|205.234.109.19|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://rubyforge-files.ruby-forum.com/rubygems/rubygems-1.2.0.tgz [following]
--23:47:11--  http://rubyforge-files.ruby-forum.com/rubygems/rubygems-1.2.0.tgz
Resolving rubyforge-files.ruby-forum.com... 88.198.17.227
Connecting to rubyforge-files.ruby-forum.com|88.198.17.227|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 246920 (241K) [application/x-gtar]
Saving to: `rubygems-1.2.0.tgz'

100%[=======================================>] 246,920     75.3K/s   in 3.2s

23:47:15 (75.3 KB/s) - `rubygems-1.2.0.tgz' saved [246920/246920]

$
展開する。
$ tar xvzf rubygems-1.2.0.tgz
rubygems-1.2.0/
rubygems-1.2.0/.document
rubygems-1.2.0/bin/
<<略>>
rubygems-1.2.0/test/test_gem_version_option.rb
rubygems-1.2.0/test/test_kernel.rb
rubygems-1.2.0/TODO
$
インストールする。
# cd /home/kenetsu/Src/Ruby/rubygems-1.2.0
# ruby setup.rb
mkdir -p /usr/lib/ruby/site_ruby/1.8
mkdir -p /usr/bin
install -c -m 0644 rubygems.rb /usr/lib/ruby/site_ruby/1.8/rubygems.rb
<<略>>
RubyGems installed the following executables:
/usr/bin/gem

If `gem` was installed by a previous RubyGems installation, you may need
to remove it by hand.

#

その0・概要
その1・RubyのRPMパッケージのビルドとインストール
その2・RubyGemsのインストール
その3・Gemパッケージのインストール

Ruby on Rails 2.1 on CentOS 5.2・その1・RubyのRPMパッケージのビルドとインストール

Ruby on Rails (RoR)には、Rubyが必要。RoR 2.1の場合、Ruby 1.8.6が推奨バージョン。1.8.[542]でも動くが、1.8.[37]では動かない(『Get Ruby on Rails in no time』)。一方、CentOS 5.2の標準RPMパッケージでは、
$ rpm -q ruby
ruby-1.8.5-5.el5_1.1
$
とある通り、1.8.5。従って、CentOS 5.2標準のままでも、RoR 2.1は動作する。しかし今回は、1.8.6のRPMを準備した。RPMのビルド環境の準備に関しては、『RHL9用のbind-9.2.8.*.rpmを作る』を参照。
$ mkdir -p RPM/BUILD RPM/RPMS/i386 RPM/SOURCES RPM/SRPMS RPM/SPECS
$ echo %_topdir $PWD/RPM > ~/.rpmmacros
$
SRPMパッケージは、Fedora 9のものを使用する。『Fedora Public Active Mirrors』から適切なサイトを選び、最新のSRPMをダウンロードする。
$ cd RPM/SRPMS
$ wget http://ftp.jaist.ac.jp/pub/Linux/Fedora/updates/9/SRPMS/ruby-1.8.6.230-4.fc9.src.rpm
--23:32:32--  http://ftp.jaist.ac.jp/pub/Linux/Fedora/updates/9/SRPMS/ruby-1.8.6.230-4.fc9.src.rpm
Resolving ftp.jaist.ac.jp... 150.65.7.130
Connecting to ftp.jaist.ac.jp|150.65.7.130|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5057508 (4.8M) [application/x-wais-source]
Saving to: `ruby-1.8.6.230-4.fc9.src.rpm'

100%[=======================================>] 5,057,508   81.5K/s   in 59s

23:33:34 (83.6 KB/s) - `ruby-1.8.6.230-4.fc9.src.rpm' saved [5057508/5057508]

$
ビルドする。
$ rpmbuild --rebuild ruby-1.8.6.230-4.fc9.src.rpm
Installing ruby-1.8.6.230-4.fc9.src.rpm
warning: InstallSourcePackage: Header V3 DSA signature: NOKEY, key ID 4f2a6fd2
warning: user mockbuild does not exist - using root
<<略>>
+ cd /home/kenetsu/RPM/BUILD
+ rm -rf ruby-1.8.6.230
+ exit 0
$
できたRPMをインストールする。
# cd /home/kenetsu/RPM/RPMS/i386
# rpm -Uvh *.rpm
Preparing...                ########################################### [100%]
1:ruby-libs              ########################################### [ 10%]
2:ruby                   ########################################### [ 20%]
3:ruby-irb               ########################################### [ 30%]
4:ruby-rdoc              ########################################### [ 40%]
5:ruby-debuginfo         ########################################### [ 50%]
6:ruby-devel             ########################################### [ 60%]
7:ruby-docs              ########################################### [ 70%]
8:ruby-mode              ########################################### [ 80%]
9:ruby-ri                ########################################### [ 90%]
10:ruby-tcltk             ########################################### [100%]
#


その0・概要
その1・RubyのRPMパッケージのビルドとインストール
その2・RubyGemsのインストール
その3・Gemパッケージのインストール

Ruby on Rails 2.1 on CentOS 5.2・その0・概要

CentOS 5.2上でRuby on Rails(RoR) version 2.1を試してみる。このシリーズでは、『Ruby on Rail チュートリアル』が動くことを目標とする。

まずはインストール。次の作業を行う。
  1. RubyのRPMパッケージのビルドとインストール
  2. RubyGemsのインストール
  3. Gemパッケージのインストール
RubyのRPMパッケージについては、必須ではない。CentOS標準のRPMパッケージでもRoRは動くはずだ。
Gemパッケージのインストールでは、『Get Ruby on Rails in no time』にある手順に加え、Gemパッケージsqlite3-rubyをインストールする。ただし、現行バージョンには問題があるため、インストール後に手当てが必要。

以下、それぞれについて解説する。

その0・概要
その1・RubyのRPMパッケージのビルドとインストール
その2・RubyGemsのインストール
その3・Gemパッケージのインストール