算是我的第一篇比较正规的原创内容,:)
以Ubuntu 6.06为例,服务器为Lighttpd
1。安装Ruby
sudo apt-get install ruby irb rdoc
2。安装Ruby Gems
在http://rubyforge.org/projects/rubygems/下载,解压ruby setup.rb
3。安装Rails
sudo gem install -y rails
4。安装Lighttpd
sudo apt-get install lighttpd
5。安装FastCGI
sudo apt-get install libfcgi-dev libfcgi-ruby1.8
开个irb看看是否安装成功
henry@henry-laptop:~$ irb
irb(main):001:0> require ‘fcgi’
=> true
irb(main):002:0>
6。开始配置服务器
server.modules = ( “mod_rewrite”,
“mod_accesslog”,
“mod_fastcgi”)
server.port = 80
#server.username = “username”
#server.groupname = “groupname”
server.pid-file = “/var/run/lighttpd.pid”
accesslog.filename = “/var/log/lighttpd/access_log”
server.errorlog = “/var/log/lighttpd/error_log”
server.indexfiles = ( “index.html” )
mimetype.assign = (
“.css” => “text/css”,
“.gif” => “image/gif”,
“.htm” => “text/html”,
“.html” => “text/html”,
“.jpeg” => “image/jpeg”,
“.jpg” => “image/jpeg”,
“.js” => “text/javascript”,
“.png” => “image/png”,
“.swf” => “application/x-shockwave-flash”,
“.txt” => “text/plain”
)
# Making sure file uploads above 64k always work when using IE or Safari
# For more information, see http://trac.lighttpd.net/trac/ticket/360
$HTTP[”useragent”] =~ “^(.*MSIE.*)|(.*AppleWebKit.*)$” {
server.max-keep-alive-requests = 0
}
$HTTP[”host”] == “www.firstapp.com” {
server.document-root = “/var/www/firstapp/public”
url.rewrite = ( “^/$” => “index.html”, “^([^.]+)$” => “$1.html” )
server.error-handler-404 = “/dispatch.fcgi”
fastcgi.server = ( “.fcgi” =>
( “localhost” =>
( “min-procs” => 2,
“max-procs” => 2,
“socket” => “/tmp/firstapp.fcgi.socket”,
“bin-path” => “/var/www/firstapp/public/dispatch.fcgi”,
“bin-environment” => ( “RAILS_ENV” => “production” )
)
)
)
}
$HTTP[”host”] == “www.secondapp.com” {
server.document-root = “/var/www/secondapp/public”
url.rewrite = ( “^/$” => “index.html”, “^([^.]+)$” => “$1.html” )
server.error-handler-404 = “/dispatch.fcgi”
fastcgi.server = ( “.fcgi” =>
( “localhost” =>
( “min-procs” => 2,
“max-procs” => 2,
“socket” => “/tmp/secondapp.fcgi.socket”,
“bin-path” => “/var/www/secondapp/public/dispatch.fcgi”,
“bin-environment” => ( “RAILS_ENV” => “production” )
)
)
)
}
如果要是部署Rails虚拟主机可能会用代理,这样就可以不重启整个Web服务器来更新其中的一个Rails应用了,不过用代理没什么需要配置的,只要给每个Rails应用开个不同的端口,用一个Lighttpd做前台就可以了。 |