`
hot88zh
  • 浏览: 179417 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

在Linux平台上用lighttpd+FastCGI部署rails问题点滴

阅读更多

具体方法参照Robbin的这篇文章~~http://www.iteye.com/topic/43228

 

我就说说自己遇到的问题:

 

问题1:pcre库没有安装,导致配置lighttpd出现错误。

解决方法:

①wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.6.tar.bz2,从官方下载最新的pcre

②然后解压tar xjvf pcre-7.6.tar.bz2

③进入到解压目录,保持默认安装路径安装:

./configure

make

make install

安装结束以后,pcre就安装成功啦。

 

 

问题2:配置lighttpd,找不到socket路径。

解决方法:

①输入vi /etc/lighttpd/lighttpd.conf,进入到lighttpd配置文件。

②保证需要的模块前面没有注释符号,mod_rewrite,mod_access,mod_fastcgi,mod_simple_vhost,mod_cgi,mod_compress,mod_accesslog,这些一般是必须的。

③找到配置rails的部分:

$HTTP["host"] == "www.xxx.com" { 
 server.document-root = "/yourrails/public" 
 server.error-handler-404 = "/dispatch.fcgi" 
 fastcgi.server = (".fcgi" => 
    ("localhost" => 
      ("min-procs" => 10, 
       "max-procs" => 10, 
       "socket" => "/tmp/lighttpd/socket/rails.socket", 
       "bin-path" => "/yourrails/public/dispatch.fcgi", 
       "bin-environment" => ("RAILS_ENV" => "production") 
      ) 
    ) 
 ) 
} 

注意那个socket的部分,那个/tmp/lighttpd/socket目录必须存在,当然你可以指定到其它目录,后面的rails.socket不用管,当lighttpd启动之后,会建立10个rails.socket,这个数量取决于你前面定义的max-procs和min-procs。还有注意把www.xxx.com修改为你自己的域名,yourrails改为你自己的rails项目所在的文件夹。

 

 

问题3:启动lighttpd,屏幕显示OK,但是没有启动

解决方法:

①查看error.log文件,具体的存放位置跟你配置lighttpd文件里面定义的位置有关。

②如果提示dispatch.fcgi启动失败,就要检查你rails文件夹里面public文件夹下的dispatch.fcgi文件了。

③一般如果要是从windows平台迁移过去的rails项目,那么这个文件中的ruby路径肯定不对

#!c:/ruby/bin/ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# and the GC period is nil (turned off).  A reasonable number of requests
# could range from 10-100 depending on the memory footprint of your app.
#
# Example:
#   # Default log path, normal GC behavior.
#   RailsFCGIHandler.process!
#
#   # Default log path, 50 requests between GC.
#   RailsFCGIHandler.process! nil, 50
#
#   # Custom log path, normal GC behavior.
#   RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
#
require File.dirname(__FILE__) + "/../config/environment"
require 'fcgi_handler'

RailsFCGIHandler.process!

 注意看第一行,应该修改为本机的ruby路径,我的修改为#!/root/ruby-1.8.6/bin/ruby,具体情况根据你自己的ruby路径决定,当然,如果你不知道具体路径,可以采用一个笨方法,那就是在Linux上面建立一个rails项目,然后复制这个项目的dispatch.fcgi里面的ruby路径。。。。。

④修改dispatch.fcgi的权限,用chmod -c 777 dispatch.fcgi

问题解决~~

 

 

 

以上就是我配置lighttpd环境遇到的问题~~

1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics