2012年8月1日水曜日

[Rails][Linux]Apache+Passengerを入れる

このエントリーをはてなブックマークに追加 Clip to Evernote


WEBrickを起動したけど、ブラウザ接続できなかったので、おとなしくPassengerを入れることにした。


参考にさせていただきましたm(__)m
ApacheをWEBサーバとして利用

まずは、passengerをインストール


$ gem install passenger
Fetching: fastthread-1.0.7.gem (100%)
Building native extensions.  This could take a while...
Fetching: daemon_controller-1.0.0.gem (100%)
Fetching: passenger-3.0.15.gem (100%)
Successfully installed fastthread-1.0.7
Successfully installed daemon_controller-1.0.0
Successfully installed passenger-3.0.15
3 gems installed
Installing ri documentation for fastthread-1.0.7...
Installing ri documentation for daemon_controller-1.0.0...
Installing ri documentation for passenger-3.0.15...
Installing RDoc documentation for fastthread-1.0.7...
Installing RDoc documentation for daemon_controller-1.0.0...
Installing RDoc documentation for passenger-3.0.15...


対話式でモジュールをインストール
$ passenger-install-apache2-module
なんかいろいろ入ってないよー。でも心配しないで!
足りないやつをインストールする方法教えるから!
みたいなこと言われます。親切ですね。


私の環境で足りなかったのは以下。


Installation instructions for required software


 * To install Curl development headers with SSL support:
   Please download Curl from http://curl.haxx.se/libcurl and make sure you install it with SSL support.


 * To install Apache 2 development headers:
   Please download it from http://httpd.apache.org/


 * To install Apache Portable Runtime (APR) development headers:
   Please download it from http://httpd.apache.org/
   (APR is an integrated part of Apache.)


 * To install Apache Portable Runtime Utility (APU) development headers:
   Please download it from http://httpd.apache.org/
   (APR Utility is an integrated part of Apache.)


まずは、curlをインストール
$ sudo yum install curl-devel


次、Apache 2 development headers
$ sudo yum install httpd-devel


んで、もう一回モジュールをインストールする。
成功すると、httpd.conf とかにいろいろ書くんだよーと教えてくれるので、メモしましょう。


The Apache 2 module was successfully installed.


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


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




apacheのhttpd.confに、


   LoadModule passenger_module /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.15/ext/apache2/mod_passenger.so
   PassengerRoot /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.15
   PassengerRuby /usr/local/ruby/bin/ruby


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


を書いたら、apacheを再起動


$ service httpd restart


http://ドメイン/ にアクセスし、Welcome aboard の画面が出たら成功!


ようやっとできた~

0 件のコメント:

コメントを投稿