■OSバンドルのRuby有無確認
[root@rails01 ~]# rpm -qa | grep ruby
[root@rails01 ~]#
⇒既存Rubyは存在しないのでOK!
■インストーラダウンロード
ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz
smb経由でサーバのsrcディレクトリにアップロード。
■インストール
[root@rails01 ~]# cd /home/public/src/
[root@rails01 src]# tar -zxf ruby-1.9.2-p290.tar.gz
[root@rails01 src]# cd ruby-1.9.2-p290
[root@rails01 ruby-1.9.2-p290]# ./configure --prefix=/usr/local
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
(中略)
ruby library version = 1.9.1
configure: creating ./config.status
config.status: creating Makefile
[root@rails01 ruby-1.9.2-p290]# make
gcc -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initiali zers -Wno-long-long -I. -I.ext/include/x86_64-linux -I./include -I. -DRUBY_EXPORT -o main.o -c main.c
gcc -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initiali zers -Wno-long-long -I. -I.ext/include/x86_64-linux -I./include -I. -DRUBY_EXPORT -o dln.o -c dln.c
(中略:10分くらい)
Generating file member index...
Generating page index...
./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb -e 'File.open("doc/capi/.timestamp", "w"){|f| f.puts(Time.now)}'
[root@rails01 ruby-1.9.2-p290]# make install
(中略)
installing manpages: /usr/local/ruby/share/man/man1
installing default gems: /usr/local/ruby/lib/ruby/gems/1.9.1 (cache, doc, gems, specifications)
rake 0.8.7
rdoc 2.5.8
minitest 1.6.0
⇒バージョン確認
[root@rails01 ~]# ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
[root@rails01 ~]# gem -v
1.3.7
■Railsインストール
[root@rails01 ~]# gem install rails
Building native extensions. This could take a while...
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Successfully installed multi_json-1.0.3
Successfully installed activesupport-3.1.0
Successfully installed builder-3.0.0
Successfully installed i18n-0.6.0
Successfully installed bcrypt-ruby-3.0.1
Successfully installed activemodel-3.1.0
Successfully installed rack-1.3.3
Successfully installed rack-cache-1.0.3
Successfully installed rack-test-0.6.1
Successfully installed rack-mount-0.8.3
Successfully installed hike-1.2.1
Successfully installed tilt-1.3.3
Successfully installed sprockets-2.0.0
Successfully installed erubis-2.7.0
Successfully installed actionpack-3.1.0
Successfully installed arel-2.2.1
Successfully installed tzinfo-0.3.29
Successfully installed activerecord-3.1.0
Successfully installed activeresource-3.1.0
Successfully installed mime-types-1.16
Successfully installed polyglot-0.3.2
Successfully installed treetop-1.4.10
Successfully installed mail-2.3.0
Successfully installed actionmailer-3.1.0
Successfully installed thor-0.14.6
Successfully installed rack-ssl-1.3.2
Successfully installed rdoc-3.9.4
Successfully installed railties-3.1.0
Successfully installed bundler-1.0.18
Successfully installed rails-3.1.0
30 gems installed
Installing ri documentation for multi_json-1.0.3...
Installing ri documentation for activesupport-3.1.0...
Installing ri documentation for builder-3.0.0...
unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README, skipping
unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README.rdoc, skipping
Installing ri documentation for i18n-0.6.0...
Installing ri documentation for bcrypt-ruby-3.0.1...
Installing ri documentation for activemodel-3.1.0...
Installing ri documentation for rack-1.3.3...
Installing ri documentation for rack-cache-1.0.3...
Installing ri documentation for rack-test-0.6.1...
Installing ri documentation for rack-mount-0.8.3...
Installing ri documentation for hike-1.2.1...
Installing ri documentation for tilt-1.3.3...
Installing ri documentation for sprockets-2.0.0...
Installing ri documentation for erubis-2.7.0...
Installing ri documentation for actionpack-3.1.0...
Installing ri documentation for arel-2.2.1...
Installing ri documentation for tzinfo-0.3.29...
Installing ri documentation for activerecord-3.1.0...
Installing ri documentation for activeresource-3.1.0...
Installing ri documentation for mime-types-1.16...
Installing ri documentation for polyglot-0.3.2...
Installing ri documentation for treetop-1.4.10...
Installing ri documentation for mail-2.3.0...
Installing ri documentation for actionmailer-3.1.0...
Installing ri documentation for thor-0.14.6...
Installing ri documentation for rack-ssl-1.3.2...
Installing ri documentation for rdoc-3.9.4...
Installing ri documentation for railties-3.1.0...
Installing ri documentation for bundler-1.0.18...
Installing ri documentation for rails-3.1.0...
file 'lib' not found
Installing RDoc documentation for multi_json-1.0.3...
Installing RDoc documentation for activesupport-3.1.0...
Installing RDoc documentation for builder-3.0.0...
unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README, skipping
unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README.rdoc, skipping
Installing RDoc documentation for i18n-0.6.0...
Installing RDoc documentation for bcrypt-ruby-3.0.1...
Installing RDoc documentation for activemodel-3.1.0...
Installing RDoc documentation for rack-1.3.3...
Installing RDoc documentation for rack-cache-1.0.3...
Installing RDoc documentation for rack-test-0.6.1...
Installing RDoc documentation for rack-mount-0.8.3...
Installing RDoc documentation for hike-1.2.1...
Installing RDoc documentation for tilt-1.3.3...
Installing RDoc documentation for sprockets-2.0.0...
Installing RDoc documentation for erubis-2.7.0...
Installing RDoc documentation for actionpack-3.1.0...
Installing RDoc documentation for arel-2.2.1...
Installing RDoc documentation for tzinfo-0.3.29...
Installing RDoc documentation for activerecord-3.1.0...
Installing RDoc documentation for activeresource-3.1.0...
Installing RDoc documentation for mime-types-1.16...
Installing RDoc documentation for polyglot-0.3.2...
Installing RDoc documentation for treetop-1.4.10...
Installing RDoc documentation for mail-2.3.0...
Installing RDoc documentation for actionmailer-3.1.0...
Installing RDoc documentation for thor-0.14.6...
Installing RDoc documentation for rack-ssl-1.3.2...
Installing RDoc documentation for rdoc-3.9.4...
Installing RDoc documentation for railties-3.1.0...
Installing RDoc documentation for bundler-1.0.18...
Installing RDoc documentation for rails-3.1.0...
file 'lib' not found
⇒バージョン確認
[root@rails01 ~]# rails --version
Rails 3.1.0
■サンプルプロジェクト作成
[root@rails01 ~]# mkdir rails_projects
[root@rails01 ~]# cd rails_projects/
[root@rails01 rails_projects]# rails new sample -d mysql
create
create README
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/images/rails.png
create app/assets/javascripts/application.js
create app/assets/stylesheets/application.css
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/mailers
create app/models
create app/views/layouts/application.html.erb
create app/mailers/.gitkeep
create app/models/.gitkeep
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/backtrace_silencers.rb
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/wrap_parameters.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 lib/assets
create lib/assets/.gitkeep
create log
create log/.gitkeep
create public
create public/404.html
create public/422.html
create public/500.html
create public/favicon.ico
create public/index.html
create public/robots.txt
create script
create script/rails
create test/fixtures
create test/fixtures/.gitkeep
create test/functional
create test/functional/.gitkeep
create test/integration
create test/integration/.gitkeep
create test/unit
create test/unit/.gitkeep
create test/performance/browsing_test.rb
create test/test_helper.rb
create tmp/cache
create tmp/cache/assets
create vendor/assets/stylesheets
create vendor/assets/stylesheets/.gitkeep
create vendor/plugins
create vendor/plugins/.gitkeep
run bundle install
Fetching source index for http://rubygems.org/
Installing rake (0.9.2)
Using multi_json (1.0.3)
Using activesupport (3.1.0)
Using bcrypt-ruby (3.0.1)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.0)
Using erubis (2.7.0)
Using rack (1.3.3)
Using rack-cache (1.0.3)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.0)
Using actionpack (3.1.0)
Using mime-types (1.16)
Using polyglot (0.3.2)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.1.0)
Using arel (2.2.1)
Using tzinfo (0.3.29)
Using activerecord (3.1.0)
Using activeresource (3.1.0)
Installing ansi (1.3.0)
Using bundler (1.0.18)
Installing coffee-script-source (1.1.2)
Installing execjs (1.2.6)
Installing coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using rdoc (3.9.4)
Using thor (0.14.6)
Using railties (3.1.0)
Installing coffee-rails (3.1.1)
Installing jquery-rails (1.0.14)
Installing mysql2 (0.3.7) with native extensions
Using rails (3.1.0)
Installing sass (3.1.7)
Installing sass-rails (3.1.2)
Installing turn (0.8.2)
Installing uglifier (1.0.3)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
[root@rails01 rails_projects]#
■データベース準備
[root@rails01 ~]# /etc/init.d/mysqld start
MySQL を起動中: [ OK ]
⇒プロジェクトディレクトリに移動してデータベース作成
[root@rails01 ~]# cd /root/rails_projects/sample/
[root@rails01 sample]# rake db:create
(in /root/rails_projects/sample)
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.2.6/lib/execjs/runtimes.rb:46:in `autodetect'
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.2.6/lib/execjs.rb:5:in `'
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.2.6/lib/execjs.rb:4:in `'
(中略)
/usr/local/lib/ruby/1.9.1/rake.rb:1991:in `run'
/usr/local/bin/rake:31:in `'
⇒上記エラー対応のためGemfile修正
[root@rails01 sample]# vi Gemfile
[root@rails01 sample]# head Gemfile
source 'http://rubygems.org'
gem 'rails', '3.1.0'
# add 20110919
gem 'therubyracer'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
[root@rails01 sample]# bundle update
Fetching source index for http://rubygems.org/
(中略)
Installing therubyracer (0.9.4) with native extensions
Using turn (0.8.2)
Using uglifier (1.0.3)
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed.
⇒再びデータベース作成
[root@rails01 sample]# rake db:create
(in /root/rails_projects/sample)
rake aborted!
uninitialized constant Rake::DSL
/usr/local/lib/ruby/1.9.1/rake.rb:2482:in `const_missing'
(後略)
⇒上記エラー対応のためGemfile修正
[root@rails01 sample]# vi Gemfile
[root@rails01 sample]# head Gemfile
source 'http://rubygems.org'
gem 'rails', '3.1.0'
# add 20110919
gem 'therubyracer'
gem 'rake', '0.8.7'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
[root@rails01 sample]# bundle update
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Using multi_json (1.0.3)
(後略)
⇒再びデータベース作成
[root@rails01 sample]# rake db:create
(in /root/rails_projects/sample)
[root@rails01 sample]# mysqlshow
+--------------------+
| Databases |
+--------------------+
| information_schema |
| mysql |
| sample_development |
| sample_test |
| test |
+--------------------+
データベースが作成された!!
■Webサーバ起動
[root@rails01 sample]# rails s
=> Booting WEBrick
=> Rails 3.1.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-09-19 22:43:01] INFO WEBrick 1.3.1
[2011-09-19 22:43:01] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux]
[2011-09-19 22:43:01] INFO WEBrick::HTTPServer#start: pid=12327 port=3000
または、
[root@rails01 sample]# rails s > log/WEBrick.log &
[1] 25595
■ブラウザで確認
http://192.168.1.14:3000/
2011年9月19日月曜日
CentOS5.7にRuby1.9.2インストール
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿