col rails

如何开发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上
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值