col rails
如何开发JRuby+MySQL+Rails3程序?
安装JDK1.6
--------------------------
下载jdk-6u25-linux-x64.bin
chmod700jdk-6u25-linux-x64.bin
./jdk-6u25-linux-x64.bin
安装JRuby
--------------------------
下载jruby-bin-1.6.2.tar.gz
tarxvfzjruby-bin-1.6.2.tar.gz
安装GlassFish
-------------------------
下载glassfish-3.1-web-ml.zip
unzipglassfish-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
exportPATHJAVA_HOMEJRUBY_HOME
重新登录
安装rails,jdbcmysql,glassfishgem,warbler
--------------------------
geminstallrailsactiverecord-jdbcmysql-adapterglassfishwarbler
创建MySQL用户
--------------------------
mysql-uroot-p
mysql>createuserduke@localhostidentifiedby'glassfish';
mysql>grantallonhello_development.*toduke@localhost;
mysql>grantallonhello_production.*toduke@localhost;
mysql>flushprivileges;
创建hello程序
--------------------------
railsnewhello-mhttp://jruby.org/rails3.rb-dmysql
cdhello
修改config/database.yml中的MySQL用户名及口令
创建development数据库
-------------------------
rakedb:create
rakedb:migrate
创建production数据库
-------------------------
rakedb:createRAILS_ENV='production'
rakedb:migrateRAILS_ENV='production'
启动WEBrick(使用development数据库)
-------------------------
railss
检查http://localhost:3000/是否正常
启动Glassfishgem(使用production数据库)
-------------------------
确认在/etc/hosts中,127.0.0.1映射到你的机器名(用hostname命令查看)
在hello/Gemfile中添加gem'glassfish'
(itisokwithdevelopmentdatabase)
glassfishhello
(thereisaRoutingError:Noroutematches"/"withproductiondatabase)
glassfishhello-eproduction
启动GlassFish(使用development数据库)
-------------------------
asadmincreate-domain--portbase2000--domaindir.mydomain
asadminstart-domain--domaindir.mydomain
cdhello
warble
将hello.war放置到Glassfish上