rails 3.0のインストール 及び サンプルアプリケーションの作成 (2010.8.31)
Table of Contents
- gems のアップデート
- `gem` commands
- RubyGems now has platform support for IronRuby. Patch #27951 by Will Green.
- Require rubygems/custom_require if –disable-gem was set. Bug #27700 by
- RubyGems now protects against exceptions being raised by plugins.
- rubygems/builder now requires user_interaction. Ruby Bug #1040 by Phillip
- Gem::Dependency support #version_requirements= with a warning. Fix for old
- Gem::PackageTask depends on the package dir like the other rake package
- rails 3.0 のインストール
- mysql2のインストール
- passenger 2.2.15 のインストール
- サンプルアプリケーションの作成
gems のアップデート
rails 3.0 が依存する i18n は RubyGems の 1.3.6以上が必要らしく、gems をアップデート。
$ sudo gem install rubygems-update Successfully installed rubygems-update-1.3.7 1 gem installed Installing ri documentation for rubygems-update-1.3.7... Installing RDoc documentation for rubygems-update-1.3.7... Could not find main page README Could not find main page README Could not find main page README Could not find main page README
#+BEGIN_EXAMPLE $ sudo /var/lib/gems/1.8/bin/update_rubygems RubyGems 1.3.7 installed
=
1.3.7 / 2010-05-13
NOTE:
http://rubygems.org is now the default source for downloading gems.
You may have sources set via ~/.gemrc, so you should replace http://gems.rubyforge.org with http://rubygems.org
http://gems.rubyforge.org will continue to work for the forseeable future.
New features:
`gem` commands
- `gem install` and `gem fetch` now report alternate platforms when a matching one couldn't be found.
- `gem contents` –prefix is now the default as specified in –help. Bug #27211 by Mamoru Tasaka.
- `gem fetch` can fetch of old versions again. Bug #27960 by Eric Hankins.
- `gem query` and friends output now lists platforms. Bug #27856 by Greg Hazel.
- `gem server` now allows specification of multiple gem dirs for documentation. Bug #27573 by Yuki Sonoda.
- `gem unpack` can unpack gems again. Bug #27872 by Timothy Jones.
- `gem unpack` now unpacks remote gems.
- –user-install is no longer the default. If you really liked it, see Gem::ConfigFile to learn how to set it by default. (This change was made in 1.3.6)
RubyGems now has platform support for IronRuby. Patch #27951 by Will Green.
Bug fixes:
Require rubygems/custom_require if –disable-gem was set. Bug #27700 by
Roger Pack.
RubyGems now protects against exceptions being raised by plugins.
rubygems/builder now requires user_interaction. Ruby Bug #1040 by Phillip
Toland.
Gem::Dependency support #version_requirements= with a warning. Fix for old
Rails versions. Bug #27868 by Wei Jen Lu.
Gem::PackageTask depends on the package dir like the other rake package
tasks so dependencies can be hooked up correctly.
RubyGems installed the following executables: /usr/bin/gem1.8 #+END_EXAMPLE
rails 3.0 のインストール
$ sudo gem install rails -v '3.0.0' Successfully installed i18n-0.4.1 Successfully installed activemodel-3.0.0 Successfully installed rack-1.2.1 Successfully installed rack-test-0.5.4 Successfully installed rack-mount-0.6.12 Successfully installed tzinfo-0.3.23 Successfully installed abstract-1.0.0 Successfully installed erubis-2.6.6 Successfully installed actionpack-3.0.0 Successfully installed arel-1.0.1 Successfully installed activerecord-3.0.0 Successfully installed activeresource-3.0.0 Successfully installed mime-types-1.16 Successfully installed polyglot-0.3.1 Successfully installed treetop-1.4.8 Successfully installed mail-2.2.5 Successfully installed actionmailer-3.0.0 Successfully installed thor-0.14.0 Successfully installed railties-3.0.0 Successfully installed bundler-1.0.0 Successfully installed rails-3.0.0 21 gems installed Installing ri documentation for i18n-0.4.1... Installing ri documentation for activemodel-3.0.0... Installing ri documentation for rack-1.2.1... Installing ri documentation for rack-test-0.5.4... Installing ri documentation for rack-mount-0.6.12... Installing ri documentation for tzinfo-0.3.23... Installing ri documentation for abstract-1.0.0... Installing ri documentation for erubis-2.6.6... Installing ri documentation for actionpack-3.0.0... Installing ri documentation for arel-1.0.1... Installing ri documentation for activerecord-3.0.0... Installing ri documentation for activeresource-3.0.0... Installing ri documentation for mime-types-1.16... Installing ri documentation for polyglot-0.3.1... Installing ri documentation for treetop-1.4.8... Installing ri documentation for mail-2.2.5... Installing ri documentation for actionmailer-3.0.0... Installing ri documentation for thor-0.14.0... Installing ri documentation for railties-3.0.0... Installing ri documentation for bundler-1.0.0... Installing ri documentation for rails-3.0.0... File not found: lib
mysql2のインストール
mysql2 というのも必要なようである
$ sudo gem install mysql2 Building native extensions. This could take a while... Successfully installed mysql2-0.2.3 1 gem installed Installing ri documentation for mysql2-0.2.3... Enclosing class/module 'mMysql2' for class Result not known Enclosing class/module 'mMysql2' for class Client not known Installing RDoc documentation for mysql2-0.2.3... Enclosing class/module 'mMysql2' for class Result not known Enclosing class/module 'mMysql2' for class Client not known
passenger 2.2.15 のインストール
$ sudo gem install passenger Building native extensions. This could take a while... Successfully installed passenger-2.2.15 1 gem installed Installing ri documentation for passenger-2.2.15... Installing RDoc documentation for passenger-2.2.15... yushi@mozuku2:/var/www/html$ sudo passenger-install-apache2-module Welcome to the Phusion Passenger Apache 2 module installer, v2.2.15. 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. -------------------------------------------- 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 * rack... found * Apache 2... found at /usr/sbin/apache2 * Apache 2 development headers... found at /usr/bin/apxs2 * Apache Portable Runtime (APR) development headers... found at /usr/bin/apr-1-config * Apache Portable Runtime Utility (APU) development headers... found at /usr/bin/apu-1-config -------------------------------------------- Compiling and installing Apache 2 module... cd /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15 /usr/bin/ruby1.8 -S /usr/bin/rake clean apache2 # /usr/bin/ruby1.8 -S /usr/bin/rake clean apache2 (in /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15) rm -rf ext/apache2/libboost_oxt.a ext/apache2/libboost_oxt rm -rf ext/apache2/libpassenger_common.a ext/apache2/ApplicationPoolServerExecutable ext/apache2/libpassenger_common rm -rf ext/apache2/Configuration.o ext/apache2/Bucket.o ext/apache2/Hooks.o ext/apache2/mod_passenger.o ext/apache2/mod_passenger.so rm -rf ext/nginx/libboost_oxt.a ext/nginx/libboost_oxt rm -rf ext/nginx/libpassenger_common.a ext/nginx/libpassenger_common rm -rf ext/nginx/HelperServer rm -rf test/libboost_oxt.a test/libboost_oxt rm -rf test/libpassenger_common.a test/ApplicationPoolServerExecutable test/libpassenger_common rm -rf test/oxt/oxt_test_main test/oxt/*.o test/CxxTests test/*.o rm -r pkg cd ext/phusion_passenger && make clean rm -f ext/phusion_passenger/Makefile mkdir -p ext/apache2/libpassenger_common g++ -Iext -Iext/common -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/libpassenger_common/Utils.o -c ext/common/Utils.cpp g++ -Iext -Iext/common -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/libpassenger_common/Logging.o -c ext/common/Logging.cpp g++ -Iext -Iext/common -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/libpassenger_common/SystemTime.o -c ext/common/SystemTime.cpp g++ -Iext -Iext/common -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/libpassenger_common/CachedFileStat.o -c ext/common/CachedFileStat.cpp g++ -Iext -Iext/common -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/libpassenger_common/Base64.o -c ext/common/Base64.cpp mkdir -p ext/apache2/libpassenger_common rm -rf ext/apache2/libpassenger_common.a ar cru ext/apache2/libpassenger_common.a ext/apache2/libpassenger_common/*.o ranlib ext/apache2/libpassenger_common.a mkdir -p ext/apache2/libboost_oxt/boost g++ -Iext -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/libboost_oxt/boost/once.o -c ext/boost/src/pthread/once.cpp g++ -Iext -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/libboost_oxt/boost/exceptions.o -c ext/boost/src/pthread/exceptions.cpp g++ -Iext -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/libboost_oxt/boost/thread.o -c ext/boost/src/pthread/thread.cpp mkdir -p ext/apache2/libboost_oxt/oxt g++ -Iext -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/libboost_oxt/oxt/system_calls.o -c ext/oxt/system_calls.cpp g++ -Iext -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/libboost_oxt/oxt/backtrace.o -c ext/oxt/backtrace.cpp g++ -Iext -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/libboost_oxt/oxt/tracable_exception.o -c ext/oxt/tracable_exception.cpp g++ -Iext -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/libboost_oxt/oxt/thread.o -c ext/oxt/thread.cpp mkdir -p ext/apache2/libboost_oxt/boost ext/apache2/libboost_oxt/oxt rm -rf ext/apache2/libboost_oxt.a ar cru ext/apache2/libboost_oxt.a ext/apache2/libboost_oxt/boost/*.o ext/apache2/libboost_oxt/oxt/*.o ranlib ext/apache2/libboost_oxt.a g++ ext/common/ApplicationPoolServerExecutable.cpp -o ext/apache2/ApplicationPoolServerExecutable -Iext -Iext/common -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS ext/apache2/libpassenger_common.a ext/apache2/libboost_oxt.a -lpthread gcc -Iext -Iext/common -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/mod_passenger.o -c ext/apache2/mod_passenger.c g++ -Iext -Iext/common -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/Configuration.o -c ext/apache2/Configuration.cpp g++ -Iext -Iext/common -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/Bucket.o -c ext/apache2/Bucket.cpp g++ -Iext -Iext/common -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/Hooks.o -c ext/apache2/Hooks.cpp g++ -shared ext/apache2/Configuration.o ext/apache2/Bucket.o ext/apache2/Hooks.o ext/apache2/mod_passenger.o -fPIC -o ext/apache2/mod_passenger.so -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/mysql -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/mysql -I/usr/include/openssl -I/usr/include/postgresql -I/usr/include/xmltok -pthread -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS ext/apache2/libpassenger_common.a ext/apache2/libboost_oxt.a -fPIC -L/usr/lib -lapr-1 -L/usr/lib -laprutil-1 -lpthread cd ext/phusion_passenger && /usr/bin/ruby1.8 extconf.rb creating Makefile cd ext/phusion_passenger && make cc -I. -I/usr/lib/ruby/1.8/i486-linux -I/usr/lib/ruby/1.8/i486-linux -I. -D_FILE_OFFSET_BITS=64 -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -c native_support.c cc -shared -o native_support.so native_support.o -L. -L/usr/lib -L. -rdynamic -Wl,-export-dynamic -lruby1.8 -------------------------------------------- The Apache 2 module was successfully installed. Please edit your Apache configuration file, and add these lines: LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15 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 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 DocumentRoot /somewhere/public # <-- be sure to point to 'public'! <Directory /somewhere/public> AllowOverride all # <-- relax Apache security settings Options -MultiViews # <-- MultiViews must be turned off </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: /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/doc/Users guide Apache.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 /usr/lib/ruby/gems/1.8/gems/passenger-2.2.7/ext/apache2/mod_passenger.so LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
/etc/apache2/mods-available/passenger.conf
<IfModule mod_passenger.c> # PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.7 PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15 PassengerRuby /usr/bin/ruby1.8 </IfModule>
サンプルアプリケーションの作成
nchak を作成
myhost:/var/www/html$ sudo rails new nchak -d mysql create create README create Rakefile create config.ru create .gitignore create Gemfile create app create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/views/layouts/application.html.erb create app/mailers create app/models create config create config/routes.rb create config/application.rb create config/environment.rb create config/environments create config/environments/production.rb create config/environments/development.rb create config/environments/test.rb create config/initializers create config/initializers/inflections.rb create config/initializers/mime_types.rb create config/initializers/secret_token.rb create config/initializers/session_store.rb create config/initializers/backtrace_silencers.rb create config/locales create config/locales/en.yml create config/boot.rb create config/database.yml create db create db/seeds.rb create doc create doc/README_FOR_APP create lib create lib/tasks create lib/tasks/.gitkeep create log create log/server.log create log/production.log create log/development.log create log/test.log create public create public/422.html create public/index.html create public/500.html create public/robots.txt create public/404.html create public/favicon.ico create public/images create public/images/rails.png create public/stylesheets create public/stylesheets/.gitkeep create public/javascripts create public/javascripts/rails.js create public/javascripts/application.js create public/javascripts/controls.js create public/javascripts/dragdrop.js create public/javascripts/prototype.js create public/javascripts/effects.js create script create script/rails create test create test/performance/browsing_test.rb create test/test_helper.rb create test/integration create test/fixtures create test/unit create test/functional create tmp create tmp/sessions create tmp/sockets create tmp/cache create tmp/pids create vendor/plugins create vendor/plugins/.gitkeep
myhost:/var/www/html$ sudo chown -R www-data.www-data nchak
rails generate migration
よくわからないが、Database schema version のところに表示されるのが、これ
myhost:/var/www/html/nchak$ sudo rails generate migration nchak_base [sudo] password for yushi: invoke active_record create db/migrate/20100831140442_nchak_base.rb
config/database.yml
# MySQL. Versions 4.1 and 5.0 are recommended. # # Install the MySQL driver: # gem install mysql2 # # And be sure to use new-style password hashing: # http://dev.mysql.com/doc/refman/5.0/en/old-client.html development: adapter: mysql2 encoding: utf8 reconnect: false database: nchak_development pool: 5 username: root password: パスワード socket: /var/run/mysqld/mysqld.sock # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: adapter: mysql2 encoding: utf8 reconnect: false database: nchak_test pool: 5 username: root password: パスワード socket: /var/run/mysqld/mysqld.sock production: adapter: mysql2 encoding: utf8 reconnect: false database: nchak_production pool: 5 username: root password: パスワード socket: /var/run/mysqld/mysqld.sock
database の作成
myhost:/var/www/html/nchak$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 548 Server version: 5.0.51a-24+lenny4 (Debian) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create database nchak_development; Query OK, 1 row affected (0.00 sec) mysql> exit Bye
rake db:migrate
myhost:/var/www/html/nchak$ sudo rake db:migrate (in /var/www/html/nchak) == NchakBase: migrating ====================================================== == NchakBase: migrated (0.0001s) =============================================
passenger経由の場合
下記が必要
RailsEnv development
コントローラの作成
myhost:/var/www/html/nchak$ sudo rails generate controller tasks index create app/controllers/tasks_controller.rb route get "tasks/index" invoke erb create app/views/tasks create app/views/tasks/index.html.erb invoke test_unit create test/functional/tasks_controller_test.rb invoke helper create app/helpers/tasks_helper.rb invoke test_unit create test/unit/helpers/tasks_helper_test.rb
routes.rb を編集
myhost:/var/www/html/nchak/config$ sudo vi routes.rb
Nchak::Application.routes.draw do # get "tasks/index" resources :tasks, :only => [ :index ] (中略) end
以降は
手順通りやっていけばOK
第8回まで終了