徒然なるままに、日ぐらしP/Cに向ひて――
メインメニュー
ブログカレンダー
2012年 12月
« 11月   1月 »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
WordPress カテゴリ一覧
WordPress 検索


富士カメラ5

Kestrel とは、チョウゲンボウのことです。ハトくらいの小さな猛禽類、つまりワシの仲間で、ハヤブサに似ています。
チョウゲンボウにはホバリングという特技があります。よく農地の上空で空中に停止している姿が見られます。小さいけれどカッコイイ、そして最近は都会でも繁殖している頼もしいタカです。
このサイトのURLは、そんなチョウゲンボウから名前を借りました。

2012年12月11日(火曜日)

railsの起動に、Phusion Passengerを使う

カテゴリー: - flyman @ 22時34分28秒

Railsの開発にはAptanaStudioを使っている。動作テストはWEBRickで行っているが、mongrelを走らせようとしたところ、エラーで起動できなかった。
で、色々ググってみたがよく分からなかったので、本番環境用にはapache+passengerを使うことにした。

以下、passengerのインストールとセットアップの覚え書きだ。
なお、環境は
CentOS 6.3
ruby 1.8.7
rails 3.2.8
gem 1.8.24
Apache/2.2.15
といった感じだ。

まず、passengerのインストーラーを入れる

# gem install passenger --no-rdoc --no-ri

続いてApacheモジュールを入れる

# passenger-install-apache2-module

これは対話型のインストーラで、不足モジュールについてはインストール方法が表示されるので、指示に従う。
例えば、こんなメッセージが表示される

Welcome to the Phusion Passenger Apache 2 module installer, v3.0.18.
	
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.
	
--------------------------------------------
	
Checking for required software...
	
 * GNU C++ compiler... found at /usr/bin/g++
 * Curl development headers with SSL support... not found
 * OpenSSL development headers... found
 * Zlib development headers... found
 * Ruby development headers... found
 * OpenSSL support for Ruby... found
 * RubyGems... found
 * Rake... found at /usr/bin/rake
 * rack... found
 * Apache 2... found at /usr/sbin/httpd
 * Apache 2 development headers... not found
 * Apache Portable Runtime (APR) development headers... not found
 * Apache Portable Runtime Utility (APU) development headers... not found
	
Some required software is not installed.
But don't worry, this installer will tell you how to install them.
	
Press Enter to continue, or Ctrl-C to abort.
	
--------------------------------------------
	
Installation instructions for required software
	
 * To install Curl development headers with SSL support:
   Please run yum install curl-devel as root.
	
 * To install Apache 2 development headers:
   Please run yum install httpd-devel as root.
	
 * To install Apache Portable Runtime (APR) development headers:
   Please run yum install apr-devel as root.
	
 * To install Apache Portable Runtime Utility (APU) development headers:
   Please run yum install apr-util-devel as root.
	
If the aforementioned instructions didn’t solve your problem, then please take
a look at the Users Guide:
	
  /usr/lib/ruby/gems/1.8/gems/passenger-3.0.18/doc/Users guide Apache.html
#

足りないものの入れ方が表示されるので、それに従って不足モジュールをインストールする。ちなみに、apr-devel と apr-util-devel は、httpd-devel と一緒に入ったので、単独でのインストールはしなかった。
すべて入れたら、再度

# passenger-install-apache2-module

を実行する。

The Apache 2 module was successfully installed.
	
Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.18/ext/apache2/mod_passenger.so
   PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.18
   PassengerRuby /usr/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.

『successfully installed』と表示され、無事インストールできた。
指示通り、設定ファイルに追記するが、/etc/httpd/conf.d/passenger.conf を作り、そこに追記するとすっきりする。

さらに、

Apache configuration file and set its DocumentRoot to /somewhere/public:

   <virtualhost *:80>
      ServerName www.yourhost.com
      # !!! Be sure to point DocumentRoot to ‘public’!
      DocumentRoot /somewhere/public
      <directory /somewhere/public>
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
      </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/lib/ruby/gems/1.8/gems/passenger-3.0.18/doc/Users guide Apache.html
	
Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl)  :-)
https://www.phusionpassenger.com
	
Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.
#

と表示されるので、自分の環境に合わせて記述する。

# service httpd restart

とかしてapacheを再起動し、VirtualhostのURLにアクセスすれば、railsアプリが起動する。

railsアプリのディレクトリ所有者はroot以外にしておくことが必要。
それから、flymanの環境では、productionでは動かず、Virtualhost に『RailsEnv development
』とか書いて development環境で動かした。これについては、調査する予定だ。


TrackBacks

このコメントのRSS

TrackBack URL : http://www.kestrel.jp/modules/wordpress/wp-trackback.php/859

この投稿には、まだコメントが付いていません

コメント

_CM_NOTICE

20 queries. 0.023 sec.
Powered by WordPress Module based on WordPress ME & WordPress

ヘッドライン
テーマ選択

(4 テーマ)