安装fcgi时出现Rails错误:无法构建gem原生扩展

Pau*_* S. 5 ruby ruby-on-rails ruby-on-rails-3

我在运行命令

bundle install
Run Code Online (Sandbox Code Playgroud)

在我的Rails项目中,它给出了错误:

...
Using activerecord (3.0.11) 
Using activeresource (3.0.11) 
Using bigdecimal (1.1.0) 
Installing fcgi (0.8.8) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /home/jjboat/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 
checking for fcgiapp.h... no
checking for fastcgi/fcgiapp.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
Run Code Online (Sandbox Code Playgroud)

Boz*_*sov 18

您需要安装fcgi开发包才能构建本机扩展(并且您必须在此之前安装C构建链).你没有在这里指定你的发行版,但是在Red Hat(以及Fedora等衍生产品)上你通常会这样做:

sudo yum install fcgi-devel
Run Code Online (Sandbox Code Playgroud)

在Debian(和Ubuntu)上你可以像这样做:

sudo apt-get install libfcgi-dev
Run Code Online (Sandbox Code Playgroud)

我不是百分之百确定Debian中包的名称,但是你应该很容易弄明白.

  • 看来这个包在Ubuntu中实际上叫做`libfcgi-dev`. (2认同)

Arm*_*ghi 8

如果你在MacOS X上使用fcgi gem遇到同样的错误(在10.7.5上测试).您可以使用homebrew(http://mxcl.github.com/homebrew/)获取所需的开发包:

brew install fcgi
Run Code Online (Sandbox Code Playgroud)

然后你应该都设置安装gem:

gem install fcgi -v '0.8.8'
Run Code Online (Sandbox Code Playgroud)