ホーム   »  スポンサー広告  »     »  Ruby  »  Ruby 1.9 + Rails 3.1 + Passenger サーバ構築

上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。

Ruby 1.9 + Rails 3.1 + Passenger サーバ構築

サーバ環境構築時のメモ。

OSCentOS 5.6

実行ユーザの作成

まず Rails アプリケーションを実行するユーザを作成します。ここでは UID=903(rails), GID=903(rails) というユーザを新規に作成しています。

torao@clove$ sudo /usr/sbin/groupadd -g 903 rails
torao@clove$ sudo /usr/sbin/useradd -d /srv/www -g rails -M -r -u 903 rails

Rails アプリケーションの作成

アプリケーション名 jyro.koiroha.org でデータベースに MySQL を使用するアプリケーションを作成します。

torao@clove$ rails new jyro.koiroha.org -d mysql
      create
      create  README
      create  Rakefile
      create  config.ru
…
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

Apache 2.2 のインストール

Passenger を動作させる Apache をインストールします。

torao@clove$ wget "http://www.meisei-u.ac.jp/mirror/apache/dist//httpd/2.2.21"
torao@clove$ tar zxvf httpd-2.2.21.tar.gz
torao@clove$ ./configure --prefix=/usr/local/apache2.2.21 --with-mpm=prefork
torao@clove$ make
torao@clove$ sudo make install

Passenger のインストール

Gem を使用して Passenger をインストールします。curl-devel が必要。

torao@clove$ sudo gem install passenger
Building native extensions.  This could take a while...
Successfully installed fastthread-1.0.7
Successfully installed daemon_controller-0.2.6
Successfully installed passenger-3.0.9
3 gems installed
Installing ri documentation for fastthread-1.0.7...
Installing ri documentation for daemon_controller-0.2.6...
Installing ri documentation for passenger-3.0.9...
Installing RDoc documentation for fastthread-1.0.7...
Installing RDoc documentation for daemon_controller-0.2.6...
Installing RDoc documentation for passenger-3.0.9...
torao@clove$ sudo passenger-install-apache2-module --apxs2-path=/usr/local/apache2/bin/apxs --apr-config-path=/usr/local/apache2/bin/apr-1-config
Welcome to the Phusion Passenger Apache 2 module installer, v3.0.9.

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.
1

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

Checking for required software...

 * GNU C++ compiler... found at /usr/bin/g++
 * Curl development headers with SSL support... found
 * OpenSSL development headers... found
 * Zlib development headers... found
 * Ruby development headers... found
 * OpenSSL support for Ruby... found
 * RubyGems... found
 * Rake... found at /usr/local/ruby-1.9.2-p290/bin/rake
 * rack... found
 * Apache 2... found at /usr/local/apache2.2.21/bin/httpd
 * Apache 2 development headers... found at /usr/local/apache2/bin/apxs
 * Apache Portable Runtime (APR) development headers... found at /usr/local/apache2/bin/apr-1-config
 * Apache Portable Runtime Utility (APU) development headers... found at /usr/local/apache2.2.21/bin/apu-1-config

--------------------------------------------
Compiling and installing Apache 2 module...
cd /usr/local/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/passenger-3.0.9
/usr/local/ruby-1.9.2-p290/bin/ruby /usr/local/ruby-1.9.2-p290/bin/rake apache2:clean apache2 RELEASE=yes
# /usr/local/ruby-1.9.2-p290/bin/ruby /usr/local/ruby-1.9.2-p290/bin/rake apache2:clean apache2 RELEASE=yes
…
gcc -shared -o passenger_native_support.so passenger_native_support.o -L. -L/usr/local/ruby-1.9.2-p290/lib -Wl,-R/usr/local/ruby-1.9.2-p290/lib -L.  -rdynamic -Wl,-export-dynamic

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

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

   LoadModule passenger_module /usr/local/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
   PassengerRoot /usr/local/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/passenger-3.0.9
   PassengerRuby /usr/local/ruby-1.9.2-p290/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.


--------------------------------------------
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:

   <VirtualHost *:80>
      ServerName www.yourhost.com
      DocumentRoot /somewhere/public    # <-- be sure to point to 'public'!
      <Directory /somewhere/public>
         AllowOverride all              # <-- relax Apache security settings
         Options -MultiViews            # <-- MultiViews must be turned off
      </Directory>
   </VirtualHost>

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

  /usr/local/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/passenger-3.0.9/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.
unicorn-config.rb の中では RAILS_ROOT (Rails.root) が使えない。 Gemfile の最後に以下を追加して bundle install を再実行。 gem 'therubyracer'
コメント
トラックバック
トラックバック URL
コメントの投稿
管理者にだけ表示を許可する
Profile
Takami Torao
Takami Torao
C/C++ 使いだった 1996年、運命の Java と出会い現在に至る。のらアーキテクト。
Yah, this is image so I don't wanna eat spam, sorry!
Search

Google
MOYO Laboratory
Web

カテゴリー
最近の記事
最近のコメント
最近のトラックバック
月別アーカイブ
ブロとも申請フォーム
RSSフィード
リンク
上記広告は1ヶ月以上更新のないブログに表示されています。新しい記事を書くことで広告を消せます。