passenger インストール
cd ~/
rbenv exec gem install passenger
rbenv rehash
passenger-install-apache2-module実行
rbenv exec passenger-install-apache2-module
passenger-install-apache2-module 詳細
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 入力
-------------------------------------------- Which languages are you interested in? Use <space> to select. If the menu doesn't display correctly, press '!' ? ? Ruby ? Python ? Node.js ? Meteor
! 入力
上下でカーソルを移動できる> (*) Ruby (*) Python (*) Node.js ( ) Meteor
Ruby を選択し、Enter 入力
-------------------------------------------- Checking for required software... * Checking for C compiler... Found: yes Location: /usr/bin/cc * Checking for C++ compiler... Found: yes Location: /usr/bin/c++ * Checking for Curl development headers with SSL support... Found: no Error: Cannot find the `curl-config` command. * Checking for OpenSSL development headers... Found: yes Location: /usr/include/openssl/ssl.h * Checking for Zlib development headers... Found: yes Location: /usr/include/zlib.h * Checking for Apache 2... Found: yes Location of httpd: /usr/sbin/apache2 Apache version: 2.4.7 * Checking for Apache 2 development headers... Found: no * Checking for Rake (associated with /home/[loginusername]/.rbenv/versions/2.1.2/bin/ruby)... Found: yes Location: /home/[loginusername]/.rbenv/versions/2.1.2/bin/ruby /home/[loginusername]/.rbenv/versions/2.1.2/bin/rake * Checking for OpenSSL support for Ruby... Found: yes * Checking for RubyGems... Found: yes * Checking for Ruby development headers... Found: yes Location: /home/[loginusername]/.rbenv/versions/2.1.2/include/ruby-2.1.0/ruby.h * Checking for rack... Found: yes * Checking for Apache Portable Runtime (APR) development headers... Found: no * Checking for Apache Portable Runtime Utility (APU) development headers... Found: no 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.
Enter 入力
-------------------------------------------- Installation instructions for required software * To install Curl development headers with SSL support: Please run apt-get install libcurl4-openssl-dev or libcurl4-gnutls-dev, whichever you prefer. * To install Apache 2 development headers: Please install it with apt-get install apache2-threaded-dev * To install Apache Portable Runtime (APR) development headers: Please install it with apt-get install libapr1-dev * To install Apache Portable Runtime Utility (APU) development headers: Please install it with apt-get install libaprutil1-dev If the aforementioned instructions didn't solve your problem, then please take a look at the Users Guide: /home/[loginusername]/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/doc/Users guide Apache.html https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html
ガイドに従い、必要なパッケージをインストールする
sudo apt-get install libcurl4-openssl-dev apache2-threaded-dev libapr1-dev libaprutil1-dev
再度インストールコマンド実行
rbenv exec passenger-install-apache2-module
再度エラーが出る場合は、パッケージインストール、
passenger-install-apache2-module
を
エラーがなくなるまで、繰り返す エラーがなくなると、自動でコンパイルが始まる
最後に以下が表示される-------------------------------------------- Almost there! Please edit your Apache configuration file, and add these lines: LoadModule passenger_module /home/[loginusername]/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so <IfModule mod_passenger.c> PassengerRoot /home/[loginusername]/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.53 PassengerDefaultRuby /home/[loginusername]/.rbenv/versions/2.1.2/bin/ruby </IfModule> After you restart Apache, you are ready to deploy any number of web applications on Apache, with a minimum amount of configuration! Press ENTER to continue.
上記をコピーし、控えておく
再度表示したい場合は、rbenv exec passenger-install-apache2-module --snippet
を実行すると 上記と同じものが表示される
Enter 入力-------------------------------------------- Deploying a web application: an example Suppose you have a web 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 # Uncomment this if you're on Apache >= 2.4: #Require all granted </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/[loginusername]/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/doc/Users guide Apache.html https://www.phusionpassenger.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.
最後にapache バーチャルホスト設定のサンプルも表示されるので、控えておく
パッセンジャー設定
新規ファイル作成
sudo vim /etc/apache2/sites-available/passenger.conf
LoadModule passenger_module /home/[loginusername]/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so
PassengerRoot /home/[loginusername]/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.53
PassengerDefaultRuby /home/[loginusername]/.rbenv/versions/2.1.2/bin/ruby
PassengerPreStart http://192.168.100.1:8080
# アクセスが存在しない場合でも終了しない
PassengerPoolIdleTime 0
# プロセスの最大起動数
PassengerMaxPoolSize 1
# プロセス生成方法(Webrikと同一動作)
RailsSpawnMethod conservative
Listen 8080
<VirtualHost *:8080>
ServerName 192.168.100.1
DocumentRoot /home/[loginusername]/works/00_release_git/MonitorSystemControlPC/App/MonitorSystem/bin/control/public
RailsEnv development
<Directory /home/[loginusername]/works/00_release_git/MonitorSystemControlPC/App/MonitorSystem/bin/control/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
Require all granted
</Directory>
</VirtualHost>
サービス再起動
sudo a2ensite passenger.conf
sudo service apache2 restart
起動時のエラーメッセージ対応
apache 起動時に以下エラーが表示される場合がある
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
このワーニングを取る設定は以下の通り
新規ファイル作成
sudo vim /etc/apache2/conf-available/fqdn.conf
設定内容は以下
ServerName [hostname]
作成した、fqdn設定を有効化
sudo a2enconf fqdn
sudo service apache2 restart
動作確認
Apacheの起動に伴い自動起動される為、PCを再起動後、以下URLへアクセスし確認する
http://192.168.100.1:8080
参考
apache バージョン確認方法
apache2 -v
で Apacheバージョンを確認する
Server version: Apache/2.4.7 (Ubuntu)
Server built: Jul 22 2014 14:36:38