Home > article > CentOS 5.4(EC2)にApache+PassengerでRails環境作る

CentOS 5.4(EC2)にApache+PassengerでRails環境作る

後々、また参照する気がするので記録しておく。この手の環境構築系のドキュメントってWikiかなんかにみんなで情報集めたらそこそこ便利そうな気がするのだけどどうだろう。

Ruby、RubyGemsのインストール

yumでRubyをインストールしようとすると、1.8.5が入ってしまうので仕方なくソースからインストール。

$ cd /usr/local/src
$ sudo wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p249.tar.gz
$ sudo tar zxvf ruby-1.8.7-p249.tar.gz
$ cd ruby-1.8.7-p249
$ sudo ./configure
$ sudo make
$ sudo make install

$ cd /usr/local/src
$ sudo wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz
$ sudo tar zxvf rubygems-1.3.6
$ cd rubygems-1.3.6
$ sudo ruby setup.rb

この時点で一応RubyGemsもインストール出来てはいるけれど、実際に使おうとするとエラーが発生する。どうやらzlibが入っていなかった模様。

$ sudo yum install zlib-devel
$ cd /usr/local/src/ruby-1.8.7-p249/ext/zlib
$ sudo extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
$ sudo make
$ sudo make install

MySQLのインストール

こっちはyumからサクッとインストール。

$ sudo yum install mysql mysql-server mysql-devel
$ sudo /etc/initd.mysqld start

my.cnfの設定は/usr/share/mysql/以下からコピーしてきたりとか適当に。ユーザの設定とかも適当に。

Apache+Passenger

まずはApacheをサクッとインストール。

$ sudo yum install httpd-devel

そしてPassengerのインストール。

$ sudo gem install passenger
$ sudo passenger-install-apache2-module

ここでまたしてもエラー。どうやらOpenSSLが入っていないとかなんとか。

$ sudo yum install openssl-devel
$ cd /usr/local/src/ruby-1.8.7-p249/ext/openssl
$ sudo ruby extconf.rb
$ sudo make
$ sudo make install

これで無事Passengerがインストール出来る。

$ sudo passenger-install-apache2-module

最低限のPassengerの設定。この設定の内容はpassenger-install-apache2-moduleを実行した時に表示されているので確認しておくこと。

$ sudo vi /etc/httpd/conf.d/passenger.conf
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.11
PassengerRuby /usr/local/bin/ruby

あとはhttpd.confのDocumentRootをRailsのpublicディレクトリにすればOK。

$ sudo vi /etc/httpd/conf/httpd.conf
DocumentRoot /path/to/rails/public

本当に最低限だけどとりあえずこれでPassengerでRailsを動かすことが出来るはず。ApacheやMySQLの自動起動はchkconfigを設定すればよい。Passengerの細かい設定はPassenger users guidを参考に。

Comments:6

from_kyushu 10-04-03 (Sat) 2:40

なんとかusers.jpがそういう役割に使われるはずだったんだろうけどね。
見事にほとんど残らなかったという……。

Anthony Behel 11-10-25 (Tue) 14:17

Hi there, just became aware of your blog through Google, and found that it is truly informative. I’m going to watch out for brussels. I’ll be grateful if you continue this in future. A lot of people will be benefited from your writing. Cheers!

Dustin Swist 11-10-30 (Sun) 15:23

I was looking through some of your posts on this website and I think this website is really instructive! Keep putting up. I really apreciated this.

Laurette Sonkens 11-10-31 (Mon) 6:29

Hey there! I’ve been following your site for a long time now and finally got the courage to go ahead and give you a shout out from Atascocita Tx! Just wanted to say keep up the excellent work!

Dacia Carberry 11-10-31 (Mon) 7:22

Hi, I think that I visited this weblog before thus I am back to enjoy the great reading. I am trying to find good information to enhance my blog! I hope its ok to borrow a few of your great ideas! You really have a talent for writing. Thank you, very much.

Mi Pinegar 11-10-31 (Mon) 9:30

Excellent post however I was wanting to know if you could write a litte more on this topic? I’d be very thankful if you could elaborate a little bit further. Many thanks!

Comment Form
Remember personal info

Trackbacks:0

Trackback URL for this entry
http://ukstudio.jp/2010/03/29/apache_passenger_rails_for_centos/trackback/
Listed below are links to weblogs that reference
CentOS 5.4(EC2)にApache+PassengerでRails環境作る from UKSTUDIO

Home > article > CentOS 5.4(EC2)にApache+PassengerでRails環境作る

Feeds
Meta
Others

Return to page top