如何开发JRuby+MySQL+Rails 3程序?
安装JDK 1.6
--------------------------
下载jdk-6u25-linux-x64.bin
chmod 700 jdk-6u25-linux-x64.bin
./jdk-6u25-linux-x64.bin
安装JRuby
--------------------------
下载jruby-bin-1.6.2.tar.gz
tar xvfz jruby-bin-1.6.2.tar.gz
安装GlassFish
-------------------------
下载glassfish-3.1-web-ml.zip
unzip glassfish-3.1-web-ml.zip
在.bash_profile中添加设置如下:
--------------------------
JAVA_HOME=$HOME/jdk1.6.0_25
JRUBY_HOME=$HOME/jruby-1.6.2
GLASSFISH_HOME=$HOME/glassfish3
PATH=$JAVA_HOME/bin:$JRUBY_HOME/bin:$GLASSFISH_HOME/bin:$PATH:$HOME/bin
export PATH JAVA_HOME JRUBY_HOME
重新登录
安装rails, jdbcmysql, glassfish gem, warbler
--------------------------
gem install rails activerecord-jdbcmysql-adapter glassfish warbler
创建MySQL用户
--------------------------
mysql -u root -p
mysql> create user duke@localhost identified by 'glassfish';
mysql> grant all on hello_development.* to duke@localhost;
mysql> grant all on hello_production.* to duke@localhost;
mysql> flush privileges;
创建hello程序
--------------------------
rails new hello -m http://jruby.org/rails3.rb -d mysql
cd hello
修改 config/database.yml中的MySQL用户名及口令
创建development数据库
-------------------------
rake db:create
rake db:migrate
创建production数据库
-------------------------
rake db:create RAILS_ENV='production'
rake db:migrate RAILS_ENV='production'
启动WEBrick (使用development数据库)
-------------------------
rails s
检查http://localhost:3000/是否正常
启动Glassfish gem(使用production数据库)
-------------------------
确认在/etc/hosts中,127.0.0.1映射到你的机器名(用hostname命令查看)
在 hello/Gemfile中添加gem 'glassfish'
(it is ok with development database)
glassfish hello
(there is a Routing Error: No route matches "/" with production database)
glassfish hello -e production
启动GlassFish(使用development数据库)
-------------------------
asadmin create-domain --portbase 2000 --domaindir . mydomain
asadmin start-domain --domaindir . mydomain
cd hello
warble
将hello.war放置到Glassfish上
安装JDK 1.6
--------------------------
下载jdk-6u25-linux-x64.bin
chmod 700 jdk-6u25-linux-x64.bin
./jdk-6u25-linux-x64.bin
安装JRuby
--------------------------
下载jruby-bin-1.6.2.tar.gz
tar xvfz jruby-bin-1.6.2.tar.gz
安装GlassFish
-------------------------
下载glassfish-3.1-web-ml.zip
unzip glassfish-3.1-web-ml.zip
在.bash_profile中添加设置如下:
--------------------------
JAVA_HOME=$HOME/jdk1.6.0_25
JRUBY_HOME=$HOME/jruby-1.6.2
GLASSFISH_HOME=$HOME/glassfish3
PATH=$JAVA_HOME/bin:$JRUBY_HOME/bin:$GLASSFISH_HOME/bin:$PATH:$HOME/bin
export PATH JAVA_HOME JRUBY_HOME
重新登录
安装rails, jdbcmysql, glassfish gem, warbler
--------------------------
gem install rails activerecord-jdbcmysql-adapter glassfish warbler
创建MySQL用户
--------------------------
mysql -u root -p
mysql> create user duke@localhost identified by 'glassfish';
mysql> grant all on hello_development.* to duke@localhost;
mysql> grant all on hello_production.* to duke@localhost;
mysql> flush privileges;
创建hello程序
--------------------------
rails new hello -m http://jruby.org/rails3.rb -d mysql
cd hello
修改 config/database.yml中的MySQL用户名及口令
创建development数据库
-------------------------
rake db:create
rake db:migrate
创建production数据库
-------------------------
rake db:create RAILS_ENV='production'
rake db:migrate RAILS_ENV='production'
启动WEBrick (使用development数据库)
-------------------------
rails s
检查http://localhost:3000/是否正常
启动Glassfish gem(使用production数据库)
-------------------------
确认在/etc/hosts中,127.0.0.1映射到你的机器名(用hostname命令查看)
在 hello/Gemfile中添加gem 'glassfish'
(it is ok with development database)
glassfish hello
(there is a Routing Error: No route matches "/" with production database)
glassfish hello -e production
启动GlassFish(使用development数据库)
-------------------------
asadmin create-domain --portbase 2000 --domaindir . mydomain
asadmin start-domain --domaindir . mydomain
cd hello
warble
将hello.war放置到Glassfish上