[:ja]Apache 上で Ruby on Rails アプリケーションを動かす[:]

[:ja]Apache 2.2 をインストールする

yum で Apache をインストール
# yum install httpd

Apacheの自動起動設定
# chkconfig httpd on

Ruby 2.1.2 をインストールする
rbenv + ruby-build を利用

gitインストール
# yum install git
# cd /opt

githubからrbenvを取得
# git clone git://github.com/sstephenson/rbenv.git

/etc/profileに環境変数を設定
# echo ‘export RBENV_ROOT=”/opt/rbenv”‘ >> /etc/profile
# echo ‘export PATH=”${RBENV_ROOT}/bin:${PATH}”‘ >> /etc/profile
# echo ‘eval “$(rbenv init -)”‘ >> /etc/profile

rbenvのpluginsフォルダの作成
# mkdir /opt/rbenv/plugins
# cd /opt/rbenv/plugins

ruby-buildをpluginsに追加
# git clone git://github.com/sstephenson/ruby-build.git

ターミナルを再起動

gcc、make、openssl-develをインストール
# yum install gcc make openssl-devel

ruby2.1.2をインストール
# rbenv install 2.1.2

ruby2.1.2を使用設定
# rbenv global 2.1.2

Phusion Passenger をインストールする

# gem install passenger
# yum install gcc gcc-c++ libcurl-devel openssl-devel zlib-devel httpd-devel apr-devel apr-util-devel ImageMagick ImageMagick-devel

ターミナルを再起動

# passenger-install-apache2-module

Apache を設定

# vi /etc/httpd/conf/httpd.conf
LoadModule passenger_module /usr/local/rbenv/パス/mod_passenger.so
PassengerRoot /usr/local/rbenv/パス/gems/passenger-バージョン
PassengerDefaultRuby /opt/rbenv/versions/2.1.2/bin/ruby
<VirtualHost *:80>
ServerName myhost.com
DocumentRoot /opt/public
<Directory /opt/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>[:]

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です