Ruby on Rails(CentOS)ã®ã¤ã³ã¹ãã¼ã«ã¡ã¢
CentOS6.4ä¸ã¸Ruby on Railsã®ç°å¢ãæ§ç¯ããã
[1]Rubyãã¤ã³ã¹ãã¼ã«ããã
[2]RubyGemsãã¤ã³ã¹ãã¼ã«ããã
[3]å種ã³ã³ãã¤ã©ãã¤ã³ã¹ãã¼ã«
# yum -y install gcc gcc-c++ openssl-devel zlib-devel make patch sqlite-devel
[4]libyamlãåå¾ãmakeãmake install ã®å®è¡
# wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
# tar -zxf yaml-0.1.4.tar.gz
# cd yaml-0.1.4
# ./configure
# make
# make install
[5]gemã³ãã³ãã«ã¦ãrailsã¢ã¸ã¥ã¼ã«ç¾¤ãã¤ã³ã¹ãã¼ã«
â»ããã§ã¯ãversion 3.2.13ãæå®ãã¦ã¤ã³ã¹ãã¼ã«ã
â»ãã¼ã¸ã§ã³æå®ããªããã°ãç¾å¨ã®ææ°çãã¤ã³ã¹ãã¼ã«ããã
# gem install rack
# gem install rails -v 3.2.13
# gem install sqlite3
[6]railsã³ãã³ãã§ãµã³ãã«ãä½æããrailsãèµ·åãã¦ã¿ãã
# rails new sample
以ä¸ã®ãããªã¨ã©ã¼ãåºããâ¦
# rails new sample
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:233:in `activate': can't activate rack (~> 1.4.5, runtime) for ["actionpack-3.2.13", "railties-3.2.13"], already activated rack-1.5.2 for ["rack-ssl-1.3.3", "railties-3.2.13"] (Gem::LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:249:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `each'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:249:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `each'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
from /usr/bin/rails:18
#
ä»ã¤ã³ã¹ãã¼ã«ããã¦ããrack(ããã§ã¯ãã¼ã¸ã§ã³1.5.2)ãã¢ã³ã¤ã³ã¹ãã¼ã«ãã
ãã¼ã¸ã§ã³1.4.5ã®rackãã¤ã³ã¹ãã¼ã«ããã
# gem uninstall rack -v 1.5.2
# gem install rack -v 1.4.5
[7]sampleãèµ·åãã
# cd sample
# rails s
ããã§ã以ä¸ã®ãããªã¨ã©ã¼ãåºãå ´åâ¦
# rails s
/usr/lib/ruby/gems/1.8/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
from /usr/lib/ruby/gems/1.8/gems/execjs-1.4.0/lib/execjs.rb:5
from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee_script.rb:1
from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee-script.rb:1
from /usr/lib/ruby/gems/1.8/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require'
from /usr/lib/ruby/gems/1.8/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1
from /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /root/sample/config/application.rb:7
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.13/lib/rails/commands.rb:53:in `require'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.13/lib/rails/commands.rb:53
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.13/lib/rails/commands.rb:50
from script/rails:6:in `require'
from script/rails:6
#
Gemfileã¸ä»¥ä¸ã®é ç®ã追å ããbundle install ãå®è¡ããã
gem 'therubyracer'
bundle installãå®è¡ããã¨ãtherubyracerãã¤ã³ã¹ãã¼ã«ãã¦ãããã
# bundle install
ã
Using sqlite3 (1.3.7)
Installing therubyracer (0.11.4)
Using uglifier (2.0.1)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
æ£å¸¸ã«å種ã¢ã¸ã¥ã¼ã«ãå
¥ã£ã¦ããã°ãrails sã³ãã³ãå®è¡å¾ã
以ä¸ã®ãã°ãåºåãããWEBrickã®èµ·åã«æåããã
ããã§ã¯ããã¼ãçªå·3000ã§èµ·åã
# rails s
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2013-05-08 07:39:44] INFO WEBrick 1.3.1
[2013-05-08 07:39:44] INFO ruby 1.8.7 (2011-06-30) [x86_64-linux]
[2013-05-08 07:39:44] INFO WEBrick::HTTPServer#start: pid=37207 port=3000