Blog信息 |
blog名称: 日志总数:1304 评论数量:2242 留言数量:5 访问次数:7572677 建立时间:2006年5月29日 |

| |
[Ruby on Rails]Ruby on Rails on Debian 软件技术
lhwork 发表于 2007/2/11 19:30:25 |
目录 [隐藏]
1 安装Ruby,Rails2 推荐安装方式3 Lighttpd4 Apache5 Database6 RadRails
[编辑]安装Ruby,Rails
aptitude install ruby libzlib-ruby rdoc irb
or
apt-get install ruby libzlib-ruby rdoc irb
测试
debian:/var/www/python# irb
irb(main):001:0> 3+5
=> 8
安装rails
从 http://rubyforge.org/frs/?group_id=307 获得安装包
如:rails-0.14.4.tgz
tar zxvf rails-0.14.4.tgz
cd rails
ruby script/server
http://locahost:3000 :) OK
[编辑]推荐安装方式
从 http://ww.ruby-lang.org/en 获得 rubytar zxvf ruby-x.y.z.tar.gzcd ruby-x.y.z./configuremake make testmake install
从http://rubygems.rubyforge.org 获得 rubygems如 tar zxvf rubygems-0.8.11.tar.gzcd rubygems-0.8.11 ruby setup.rb all
gem install rails --include-dependencies
更新 Rails
gem update rails
创建第一个应用
rails yourapp
在yourapp下新建一个控制器
ruby script/generate controller say
代码在 app/controllers/say_controller.rb,内容如下
class SayController < ApplicationControllerend
SayController继承ApplicationController
加一个hello的action,添加
def helloend
[编辑]Lighttpd
// install FastCGI
wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gztar xzvf fcgi-2.4.0.tar.gzcd fcgi-2.4.0./configure –prefix=/usr/localmakesudo make installcd ..
// 添加 Ruby-FastCGI 绑定
wget http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gztar xzvf ruby-fcgi-0.8.6.tar.gzcd ruby-fcgi-0.8.6/usr/local/bin/ruby install.rb config –prefix=/usr/local/usr/local/bin/ruby install.rb setupsudo /usr/local/bin/ruby install.rb installcd ..
// 安装 PCRE
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-6.6.tar.gztar xzvf pcre-6.6.tar.gzcd pcre-6.6./configure –prefix=/usr/local CFLAGS=-O1makesudo make installcd ..
// 安装 lighttpd
wget http://lighttpd.net/download/lighttpd-1.4.11.tar.gztar xzvf lighttpd-1.4.11.tar.gzcd lighttpd-1.4.11./configure –prefix=/usr/local –with-pcre=/usr/localmakesudo make installcd ..
启动 ruby
ruby script/server=> Booting lighttpd (use ’script/server webrick’ to force WEBrick)=> Rails application started on http://127.0.0.1:80=> Call with -d to detach=> Ctrl-C to shutdown server (see config/lighttpd.conf for options)
此时启动了 Lighttpd web serverhttp://localhost
[编辑]Apache
修改 vi /etc/apache2/sites-enabled/000-default
Alias /yourapp/ "/var/www/rails/yourapp/public/"<Location /yourapp/> Options ExecCGI FollowSymLinks AddHandler cgi-script .cgi AllowOverride all Order allow,deny Allow from all</Location>
/etc/init.d/apache2 restart
http://localhost/rails/yourapp/public/ :)
[编辑]Database
libmysql-ruby
libpgsql-ruby
libsqlite3-ruby
# apt-get install libpgsql-ruby# irbirb(main):001:0> require 'postgres'=> trueirb(main):002:0> exit
[编辑]RadRails
从 http://www.radrails.org/ 获得安装包
参考资料
Ruby on Rails on Debian
http://www.debian-administration.org/articles/329
|
|
|