Ruby on Rails on Debian

来自开放百科 - 灰狐
(版本间的差异)
跳转到: 导航, 搜索
 
(未显示3个用户的14个中间版本)
第1行: 第1行:
安装ruby
+
==ruby module==
 +
apt-get install apache2-mod-ruby
 +
/etc/init.d/apache2 force-reload to enable
 +
Apache/2.2.3 (Debian) mod_ruby/1.2.6 Ruby/1.8.5(2006-08-25)
 +
==安装Ruby,Rails==
  
 
aptitude install ruby libzlib-ruby rdoc irb  
 
aptitude install ruby libzlib-ruby rdoc irb  
第29行: 第33行:
 
http://locahost:3000  :) OK
 
http://locahost:3000  :) OK
  
参考资料
+
==推荐安装方式==
 
+
Ruby on Rails on Debian
+
 
+
http://www.debian-administration.org/articles/329
+
 
+
==推荐方式==
+
 
  从 http://ww.ruby-lang.org/en 获得 ruby
 
  从 http://ww.ruby-lang.org/en 获得 ruby
 
  tar zxvf ruby-x.y.z.tar.gz
 
  tar zxvf ruby-x.y.z.tar.gz
第45行: 第43行:
  
 
  从http://rubygems.rubyforge.org 获得 rubygems
 
  从http://rubygems.rubyforge.org 获得 rubygems
  如 tar zxvf rubygems-0.8.10.tar.gz
+
  如 tar zxvf rubygems-0.8.11.tar.gz
  cd rubygems-0.8.10
+
  cd rubygems-0.8.11
  ruby setup.rb  
+
  ruby setup.rb all
  
 
  gem install rails --include-dependencies
 
  gem install rails --include-dependencies
更新
+
更新 Rails
 
  gem update rails  
 
  gem update rails  
  
[[category:安装指南]]
+
创建第一个应用
 +
rails yourapp
 +
 
 +
在yourapp下新建一个控制器
 +
ruby script/generate controller say
 +
代码在 app/controllers/say_controller.rb,内容如下
 +
class SayController < ApplicationController
 +
end
 +
SayController继承ApplicationController
 +
 
 +
加一个hello的action,添加
 +
def hello
 +
end
 +
 
 +
==Lighttpd==
 +
// install FastCGI
 +
wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
 +
tar xzvf fcgi-2.4.0.tar.gz
 +
cd fcgi-2.4.0
 +
./configure –prefix=/usr/local
 +
make
 +
sudo make install
 +
cd ..
 +
// 添加 Ruby-FastCGI 绑定
 +
wget http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz
 +
tar xzvf ruby-fcgi-0.8.6.tar.gz
 +
cd ruby-fcgi-0.8.6
 +
/usr/local/bin/ruby install.rb config –prefix=/usr/local
 +
/usr/local/bin/ruby install.rb setup
 +
sudo /usr/local/bin/ruby install.rb install
 +
cd ..
 +
// 安装 PCRE
 +
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-6.6.tar.gz
 +
tar xzvf pcre-6.6.tar.gz
 +
cd pcre-6.6
 +
./configure –prefix=/usr/local CFLAGS=-O1
 +
make
 +
sudo make install
 +
cd ..
 +
// 安装 lighttpd
 +
wget http://lighttpd.net/download/lighttpd-1.4.11.tar.gz
 +
tar xzvf lighttpd-1.4.11.tar.gz
 +
cd lighttpd-1.4.11
 +
./configure –prefix=/usr/local –with-pcre=/usr/local
 +
make
 +
sudo make install
 +
cd ..
 +
 
 +
启动 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 server
 +
http://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
 +
# irb
 +
irb(main):001:0> require 'postgres'
 +
=> true
 +
irb(main):002:0> exit
 +
 
 +
==RadRails==
 +
从 http://www.radrails.org/ 获得安装包
 +
 +
参考资料
 +
 
 +
Ruby on Rails on Debian
 +
 
 +
http://www.debian-administration.org/articles/329
 +
 
 +
[[Category:Rails]]
 +
[[Category:Debian]]

2010年8月21日 (六) 02:24的最后版本

目录

[编辑] ruby module

apt-get install apache2-mod-ruby
/etc/init.d/apache2 force-reload to enable

Apache/2.2.3 (Debian) mod_ruby/1.2.6 Ruby/1.8.5(2006-08-25)

[编辑] 安装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 获得 ruby
tar zxvf ruby-x.y.z.tar.gz
cd ruby-x.y.z
./configure
make 
make test
make install
从http://rubygems.rubyforge.org 获得 rubygems
如 tar zxvf rubygems-0.8.11.tar.gz
cd 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 < ApplicationController
end

SayController继承ApplicationController

加一个hello的action,添加

def hello
end

[编辑] Lighttpd

// install FastCGI

wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
tar xzvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure –prefix=/usr/local
make
sudo make install
cd ..

// 添加 Ruby-FastCGI 绑定

wget http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz
tar xzvf ruby-fcgi-0.8.6.tar.gz
cd ruby-fcgi-0.8.6
/usr/local/bin/ruby install.rb config –prefix=/usr/local
/usr/local/bin/ruby install.rb setup
sudo /usr/local/bin/ruby install.rb install
cd ..

// 安装 PCRE

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-6.6.tar.gz
tar xzvf pcre-6.6.tar.gz
cd pcre-6.6
./configure –prefix=/usr/local CFLAGS=-O1
make
sudo make install
cd ..

// 安装 lighttpd

wget http://lighttpd.net/download/lighttpd-1.4.11.tar.gz
tar xzvf lighttpd-1.4.11.tar.gz
cd lighttpd-1.4.11
./configure –prefix=/usr/local –with-pcre=/usr/local
make
sudo make install
cd ..

启动 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 server
http://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
# irb
irb(main):001:0> require 'postgres'
=> true
irb(main):002:0> exit

[编辑] RadRails

http://www.radrails.org/ 获得安装包

参考资料

Ruby on Rails on Debian

http://www.debian-administration.org/articles/329

分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱