Passengerをインストールしてみる
Passengerで動かすことを想定して,ローカル環境にもインストールしてみる.
% sudo gem install passenger % sudo /var/lib/gems/1.8/bin/passenger-install-apache2-module Welcome to the Phusion Passenger Apache 2 module installer, v2.0.2. 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. 1 Checking for required software... * GNU C++ compiler... found at /usr/bin/g++ * Ruby development headers... found * OpenSSL support for Ruby... found * RubyGems... found * Rake... found at /usr/bin/rake * Apache 2... found at /usr/sbin/apache2 * Apache 2 development headers... not found * Apache Portable Runtime (APR) development headers... found * fastthread... found * rack... found 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.
と言うわけで,Apache2 の開発用パッケージが必要らしい.で,いろいろ調べると,
% sudo apache2 -V Server version: Apache/2.2.9 (Debian) Server built: Jul 20 2008 08:23:41 Server's Module Magic Number: 20051115:15 Server loaded: APR 1.2.12, APR-Util 1.2.12 Compiled using: APR 1.2.12, APR-Util 1.2.12 Architecture: 32-bit Server MPM: Prefork threaded: no forked: yes (variable process count) Server compiled with.... -D APACHE_MPM_DIR="server/mpm/prefork" -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=128 -D HTTPD_ROOT="" -D SUEXEC_BIN="/usr/lib/apache2/suexec" -D DEFAULT_PIDLOG="/var/run/apache2.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types" -D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"
と言うことで,prefork-dev をインストール.
% sudo apt-get install apache2-prefork-dev
そして再度,
% sudo /var/lib/gems/1.8/bin/passenger-install-apache2-module ...略... The Apache 2 module was successfully installed. Please edit your Apache configuration file, and add these lines: LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-2.0.2/ext/apache2/mod_passenger.so PassengerRoot /var/lib/gems/1.8/gems/passenger-2.0.2 PassengerRuby /usr/bin/ruby1.8 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 Ruby on Rails application in /somewhere. Add a virtual host to your Apache configuration file, and set its DocumentRoot to /somewhere/public, like this: <VirtualHost *:80> ServerName www.yourhost.com DocumentRoot /somewhere/public </VirtualHost> And that's it! You may also want to check the Users Guide for security and optimization tips and other useful information: /var/lib/gems/1.8/gems/passenger-2.0.2/doc/Users guide.html Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-) http://www.modrails.com/ Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.
なので,設定開始.
- /etc/apache2/mods-available/passenger.load
LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-2.0.2/ext/apache2/mod_passenger.so
- /etc/apache2/mods-available/passenger.conf
PassengerRoot /var/lib/gems/1.8/gems/passenger-2.0.2 PassengerRuby /usr/bin/ruby1.8
- シンボリックリンクを張る
% sudo ln -s /etc/apache2/mods-available/passenger.load /etc/apache2/mods-enabled/passenger.load % sudo ln -s /etc/apache2/mods-available/passenger.conf /etc/apache2/mods-enabled/passenger.conf
- VirtualHostの設定
<VirtualHost *> DocumentRoot /path/to/app/public </VirtualHost>
- fcgidを無効にしておく.
% sudo rm /etc/apache2/mods-enabled/fcgid.*
- 再起動
% sudo apache2ctl restart
これで,http://localhost/ にアクセスすると,Railsのあの画面が表示される.