AmazonEC2へのApache&Passengerインストール手順
全て「Found: yes」になると、インストールが進行します。
結構(10分くらい?)時間がかかるので、待ちましょう。
すると、下記のようなメッセージが表示されます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Welcome to the Phusion Passenger Apache 2 module installer, v4.0.29. 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. |
「Enterを押すと、Apache2モジュールがインストールされ、Apacheの設定方法とRuby on Railsアプリのデプロイ方法がわかりますよ」
というような内容です。Enterを押しましょう。そうすると、次のメッセージが。
1 2 3 4 5 6 7 8 9 10 11 12 13 | The Apache 2 module was successfully installed. Please edit your Apache configuration file , and add these lines: LoadModule passenger_module /home/ec2-user/ .rbenv /versions/2 .0.0-p247 /lib/ruby/gems/2 .0.0 /gems/passenger-4 .0.29 /buildout/apache2/mod_passenger .so PassengerRoot /home/ec2-user/ .rbenv /versions/2 .0.0-p247 /lib/ruby/gems/2 .0.0 /gems/passenger-4 .0.29 PassengerDefaultRuby /home/ec2-user/ .rbenv /versions/2 .0.0-p247 /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 . |
「LoadModule passenger_module~」
から
「PassengerDefaultRuby~」
までの行をコピーし、メモしておきましょう。
(後ほどこの内容をhttpd.confに追記します)
もう一度Enterを押すと、さらに次のメッセージが表示されます。
こちらも「~」から「~」までコピーしてメモっておきましょう。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 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: /home/ec2-user/ .rbenv /versions/2 .0.0-p247 /lib/ruby/gems/2 .0.0 /gems/passenger-4 .0.29 /doc/Users guide Apache.html http: //www .modrails.com /documentation/Users %20guide%20Apache.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. |
これで「passenger-install-apache2-module」が終了です。長かったですね。
コピーした内容をApacheの設定ファイルに反映していきます。
1 | vim /etc/httpd/conf .d /passenger .conf |
1つ目のコピー内容「LoadModule~」を貼り付け、保存します。
1 2 | cp /etc/httpd/conf/httpd .conf /etc/httpd/conf/httpd .conf.bk vim /etc/httpd/conf/httpd .conf |
(cpコマンドは、バックアップ用)
末尾に2つ目のコピー内容「<virtualHost~」を追記します。
ServerNameの「www.yourhost.com」の記述と、
ドキュメントルートの「somewhere」の記述は適宜変えてください。
ServerNameはなんでもよいのですが、
ドキュメントルートはアプリケーションの配置先になるので注意が必要です。
(私は「/var/www/testapp/testsample」としました)
「public」ディレクトリは後述のbundleコマンド時に勝手に生成されます。
初級インフラエンジニアにオススメ連載リンク
ネットワーク学習の登竜門・・
ゼロからのCCNA独学講座
Linuxの取り扱いを基礎から学ぶ
Linux資格 「LPIC-Lv1」徹底解説