Ruby Development Environment - Ruby on Rails2011/05/18 |
Install Rails to configure Ruby Development Environment.
Ruby is required to installed.
And also MySQL is also required on here.
(It's possible not only to use MySQL but SQLite and Postgres SQL, though)
|
|
[1] | Install some packages first. |
[root@rails ~]# yum -y install rubygems ruby-devel mysql-devel gcc make
|
[2] | Install Rails. This example shows to install Rails 2.x not Rails 3.x. |
[root@rails ~]# gem install rails -v=2.3.11 --include-dependencies INFO: `gem install -y` is now default and will be removed INFO: use --ignore-dependencies to install only the gems you list Successfully installed rake-0.8.7 Successfully installed activesupport-2.3.11 Successfully installed activerecord-2.3.11 Successfully installed rack-1.1.2 Successfully installed actionpack-2.3.11 Successfully installed actionmailer-2.3.11 Successfully installed activeresource-2.3.11 Successfully installed rails-2.3.11 8 gems installed Installing ri documentation for rake-0.8.7... Installing ri documentation for activesupport-2.3.11... Installing ri documentation for activerecord-2.3.11... Installing ri documentation for rack-1.1.2... Installing ri documentation for actionpack-2.3.11... Installing ri documentation for actionmailer-2.3.11... Installing ri documentation for activeresource-2.3.11... Installing ri documentation for rails-2.3.11... Installing RDoc documentation for rake-0.8.7... Installing RDoc documentation for activesupport-2.3.11... Installing RDoc documentation for activerecord-2.3.11... Installing RDoc documentation for rack-1.1.2... Installing RDoc documentation for actionpack-2.3.11... Installing RDoc documentation for actionmailer-2.3.11... Installing RDoc documentation for activeresource-2.3.11... Installing RDoc documentation for rails-2.3.11... [root@rails ~]# gem install mysql -- --with-mysql-config=/usr/bin/mysql_config Building native extensions. This could take a while... Successfully installed mysql-2.8.1 1 gem installed Installing ri documentation for mysql-2.8.1... |
[3] | Create a test application. |
[root@rails ~]# rails testapp -d mysql [root@rails ~]# cd testapp
[root@rails testapp]#
vi config/database.yml
development:
[root@rails testapp]# adapter: mysql encoding: utf8 reconnect: false database: testapp_development pool: 5 username: root password: password # set MySQL password ( set on "xxx_test" and "xxx_production" field, too ) socket: /var/lib/mysql/mysql.sock rake db:create:all # create databases (in /root/testapp) [root@rails ~]# script/generate scaffold testapp title:string body:text [root@rails testapp]# rake db:migrate # create tables (in /root/testapp) == CreateTestapps: migrating ================================================= -- create_table(:testapps) -> 0.0635s == CreateTestapps: migrated (0.0640s) ======================================== [root@rails testapp]# script/server # start WEBrick => Booting WEBrick => Rails 2.3.11 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2011-05-18 20:46:48] INFO WEBrick 1.3.1 [2011-05-18 20:46:48] INFO ruby 1.8.7 (2010-06-23) [x86_64-linux] [2011-05-18 20:46:48] INFO WEBrick::HTTPServer#start: pid=3341 port=3000 |
[4] | Access to "http://(hostname or IP address):3000/" with web browser. It's OK if the following page is shown. |
Access to "http://(hostname or IP address):3000/testapps/", then created test application is shown. | |
Click "New testapp", then it's possible to add new comment. | |
It's easy to make a base of applications if you use Ruby on Rails. | |