Posted on March 19, 2005 at 5:25 pm

Inspired by this weekend’s adventures installing Ruby on Rails w/FastCGI on a Fedora Core 1 system running Ensim 4.03. This makes it seem so easy, but it took a day of troubleshooting to work through this stuff. Hopefully this will help someone else who’s trying to make Ruby on Rails play nice on an Ensim box.

Download and install the latest version of Ruby:

wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.2.tar.gz
tar vxzf ruby-1.8.2.tar.gz
cd ruby-1.8.2
./configure
make
make install

Download and install the latest version of RubyGems:

wget http://rubyforge.org/frs/download.php/3463/rubygems-0.8.8.tgz
tar vxzf rubygems-0.8.8.tgz
cd rubygems-0.8.8
ruby setup.rb

Ruby and RubyGems should be installed now, so let’s install Rails:

gem update
gem install rails

FastCGI seems to be installed on the system, but Apache hasn’t been setup to use it. Add the following line at the bottom of the LoadModule section of /etc/httpd/conf/httpd.conf:

LoadModule fastcgi_module modules/mod_fastcgi.so

Now we need to add the FastCGI handler, so add this line right below the AddHandler line for CGI.

AddHandler fastcgi-script .fcgi .fcg .fpl

That’s all that needs to be done with Apache, so we need to restart it now:

service httpd restart

FastCGI should technically be working now, but for some reason Ruby FCGI is borked. Now we need to reinstall the Ruby FCGI gem, but it will fail because of a missing fcgiapp.h file. We need to install the FastCGI Developers Kit to get this file:

wget http://www.fastcgi.com/dist/fcgi.tar.gz
cd fcgi-2.4.0
./configure
make
make install

Now we can install the Ruby fcgi gem:

gem install fcgi -- --with-fcgi-include=/usr/local/include
--with-fcgi-lib=/usr/local/lib

Now we can create a Rails application on one of the spare websites. We’ll blow away the default html directory and replace it with a symlink to the new Rails application’s public directory:

cd /home/virtual/myfaketestsite.com/var/www
rm -rf html/
rails myapp
ln -s myapp/public html

We need to change the owner of the myapp files to be the same as the others in this site:

chown -R admin99.admin99 myapp

Point a browser at http://www.myfakewebsite.com and we should be getting the Rails congratulations page. That page needs to go, if we are going to get any further:

mv html/index.html html/index.html.bak

Refreshing the browser should show a Rails Routing Error. Excellent, so we know the dispatch.cgi page is working. Now lets switch to FastCGI. Edit the .htaccess file and change /dispatch.cgi to /dispatch.fcgi. If we refresh the browser now we should get a Rails Routing Error again.

This server has been upgraded to MySQL 4.1, and the default Ruby mysql driver won’t connect because it’s running in old_password compatibility mode (otherwise Ensim can’t connect). In order to fix it we need to reinstall the mysql-ruby client:

wget http://www.tmtm.org/en/mysql/ruby/mysql-ruby-2.5.tar.gz
tar vxzf mysql-ruby-2.5.tar.gz
cd mysql-ruby-2.5
ruby extconf.rb --with-mysql-config=/usr/bin/mysql_config

Test the connectivity before compiling:

ruby -I. ./test.rb localhost root mypassword

No errors, so install mysql-ruby:

make install
20 Comments:
Posted on March 31, 2005 at 9:35 pm by Tahir

This looks like you are installing it in the root of the server as root. I would like to install all this in the Chroot of the website that i have under ensim.

So when i try to install Rubygems i get the following errors:

[root@host3 rubygems-0.8.8]# gem update
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__’: No such file to load — zlib (LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/package.rb:9
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/builder.rb:1
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:62:in `manage_gems’
from /usr/local/bin/gem:4
[root@host3 rubygems-0.8.8]# gem install rails
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__’: No such file to load — zlib (LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/package.rb:9
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/builder.rb:1
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:62:in `manage_gems’
from /usr/local/bin/gem:4

Are these normal.

Posted on March 31, 2005 at 9:37 pm by Tahir

just noticed that the erros start happening when i run the ruby setup.rb

[root@host3 rubygems-0.8.8]# ruby setup.rb
—> bin
lib
—> lib/rubygems
bin
lib
—> lib/rubygems
bin
mkdir -p /usr/local/bin/
install gemwhich /usr/local/bin/
install gem /usr/local/bin/
install gem_server /usr/local/bin/
install generate_yaml_index.rb /usr/local/bin/
install update_rubygems /usr/local/bin/
lib
mkdir -p /usr/local/lib/ruby/site_ruby/1.8/
install ubygems.rb /usr/local/lib/ruby/site_ruby/1.8/
install rubygems.rb /usr/local/lib/ruby/site_ruby/1.8/
install gemconfigure.rb /usr/local/lib/ruby/site_ruby/1.8/
—> lib/rubygems
mkdir -p /usr/local/lib/ruby/site_ruby/1.8/rubygems
install specification.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install builder.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install command.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install config_file.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install custom_require.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install doc_manager.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install format.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install cmd_manager.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install gem_runner.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install installer.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install loadpath_manager.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install old_format.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install open-uri.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install package.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install remote_installer.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install rubygems_version.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install source_index.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install deployment.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install timer.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install user_interaction.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install validator.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install version.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install dependency_list.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems
install gem_commands.rb /usr/local/lib/ruby/site_ruby/1.8/rubygems

Posted on March 31, 2005 at 10:25 pm by Keith

Yes, I was installing as the system root. Off the top head I’m not sure what’s causing your errors, but I may try to install Rails into one of the chrooted accounts and see if I run into the same thing.

Posted on April 1, 2005 at 9:39 am by Tahir

I installed as system root and i got same errors, be sure to enable development enviroment for the install to work under chroot.

Posted on April 2, 2005 at 12:10 pm by Tahir

for some reason i had to install zlib in get rid off these errors. But it is already installed so that is very strange

Posted on April 18, 2005 at 10:57 am by Vicente Gallur

I found that page looking for the same problem as Tahir. Perhaps you have the same problem, I have instaled zlib .rpm, but there is another .rpm named zlib- -devel-* for development,

Hope it helps.

Posted on April 26, 2005 at 6:57 pm by Jay Palat

You definifely need the zlib-devel-* libraries to run gems.

Posted on May 22, 2005 at 2:38 pm by Jeff

Using Ensim 3.5 and am getting this error:

Symbolic link not allowed: /home/virtual/site2/fst/var/www/html/

How should the directory options be configured to allow the symlink from html to myapp?

Posted on July 2, 2005 at 6:46 am by Sven

Please note that you probably forgot “–” in step 8 when installing the fcgi gem. The command you stated above yields a syntax error.

gem install fcgi — –with-fcgi-include=/usr/local/include

works fine.

[...] This web page and this other one helped a bit, especially in figuring out how to get around the missing fcgiapp.h error message. [...]

Posted on September 22, 2005 at 1:07 pm by JohnO

I am having a problem with connecting to the database. I can connect through mysql (in the shell) with the appropriate user. My phpMyAdmin works fine. But my rails application fails:
No database specified. Missing argument: database

Trace:
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/mysql_adapter.rb:34:in `mysql_connection’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/query_cache.rb:52:in `send’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/query_cache.rb:52:in `connection=’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/abstract_adapter.rb:108:in `retrieve_connection’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:239:in `connection’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:461:in `count_by_sql’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:454:in `count’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/pagination.rb:154:in `count_collection_for_pagination’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/pagination.rb:171:in `paginator_and_collection_for’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/pagination.rb:111:in `paginate’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:756:in `send’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:756:in `perform_action_without_filters’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/filters.rb:295:in `perform_action_without_benchmark’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in `perform_action_without_rescue’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in `measure’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in `perform_action_without_rescue’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/rescue.rb:80:in `perform_action’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in `send’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in `process’
/usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/dispatcher.rb:32:in `dispatch’
/home/john/public_html/client_net/public/dispatch.cgi:10

Here is my correct .yml file:
development:
adapter: mysql
database:john_client_net
host: localhost
username: client_net
password: rubyonrails

I tried updating the mysql-ruby library to 2.6.3 figuring it might be the ole OLD_PASSWORD function problem (running MySQL 4.1.10), but no dice. Any one got any ideas? any place I can look to specifically find the problem?

I have a question (since I followed your last step of updating the mysql-ruby library)… does the –with-mysql-config=/usr/bin/mysql_conf option tell it to look for the configuration there? or to put it’s own configuration there??? (Because if it tells to look there, which I doubt, since it is not a plaintext file, that might be why it doesn’t connect)

I’ll be checking back.. please email me if your respond so I don’t miss it…

Posted on September 22, 2005 at 2:01 pm by Keith

mysql_config is the executable mysql configuration tool. Are you getting any errors when running “ruby extconf.rb –with-mysql-config=/usr/bin/mysql_config”?

Posted on November 22, 2005 at 6:59 pm by yoav

hey
i have installed everything, without any errors.

the only error i get is inside the fastcgi.crash.log file when try to execute dispatch.fcgi.
the error is:
[22/Nov/2005:14:25:53 :: 20815] Dispatcher failed to catch: undefined method `is_cgi?’ for FCGI:Class (NoMethodError)
/usr/lib/site_ruby/1.8/fcgi.rb:593:in `each_cgi’
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/fcgi_handler.rb:52:in `process!’
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/fcgi_handler.rb:22:in `process!’
/home/virtual/site1/fst/var/www/html/public/dispatch.fcgi:24
almost killed by this error
[22/Nov/2005:14:25:53 :: 20815] Dispatcher failed to catch: undefined method `is_cgi?’ for FCGI:Class (NoMethodError)
/usr/lib/site_ruby/1.8/fcgi.rb:593:in `each_cgi’
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/fcgi_handler.rb:52:in `process!’
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/fcgi_handler.rb:22:in `process!’
/home/virtual/site1/fst/var/www/html/public/dispatch.fcgi:24
killed by this error

i read in a few places that this is cause by a bad installation of the fcgi gem, and i should try to install it manually. well, if i install it manually, dispatch.fcgi throws out a 500 error. :)

when try to executein the browser, the browser thinks about it for a minute and then throws out a Rails failed message.

running:
ensim 4.0.4 on fedora (i think core 3), apache 2, ruby 1.8.3

please please….i’ve been trying to solve this for two days now…

thanks :)

Posted on November 22, 2005 at 7:07 pm by Admin

It seems to me that its more likely caused by a bad install of fcgi rather than the fcgi rubygem. Are you sure that fcgi compiled and installed correctly? Were there any errors when running configure or make?

Posted on November 22, 2005 at 11:58 pm by yoav

everything seems to be going flawless when installing fcgi-2.4.0.

i did it again now, and here are the last parts of ./config & make.

configure: creating ./config.status
config.status: creating Makefile
config.status: creating cgi-fcgi/Makefile
config.status: creating include/Makefile
config.status: creating libfcgi/Makefile
config.status: creating examples/Makefile
config.status: creating fcgi_config.h
config.status: fcgi_config.h is unchanged

————-

creating echo-cpp
make[2]: Leaving directory `/usr/local/src/fcgi-2.4.0/examples’
Making all in include
make[2]: Entering directory `/usr/local/src/fcgi-2.4.0/include’
make[2]: Nothing to be done for `all’.
make[2]: Leaving directory `/usr/local/src/fcgi-2.4.0/include’
make[2]: Entering directory `/usr/local/src/fcgi-2.4.0′
make[2]: Leaving directory `/usr/local/src/fcgi-2.4.0′
make[1]: Leaving directory `/usr/local/src/fcgi-2.4.0′

make install says that:
Libraries have been installed in:
/usr/local/lib

i find these files under /usr/local/include:
fastcgi.h fcgiapp.h fcgi_config.h fcgimisc.h fcgio.h fcgios.h fcgi_stdio.h

and these ones under /usr/local/lib:
libfcgi.a libfcgi.la libfcgi.so libfcgi.so.0 libfcgi.so.0.0.0
libfcgi++.a libfcgi++.la libfcgi++.so libfcgi++.so.0 libfcgi++.so.0.0.0

when doing the gem instal fcgi…. it says:
checking for fcgiapp.h... yes
checking for FCGX_Accept() in -lfcgi... yes
creating Makefile

how can i tell if fcgi was installed properly or not?

thanks…:)

Posted on November 23, 2005 at 12:19 am by yoav

in this article: http://wiki.rubyonrails.com/rails/pages/RailsOnFedora

they say to do:
NB:FastCGI installs to /usr/local/lib, so if it isn’t there already you will need to add /usr/local/lib to /etc/ld.so.conf and run:

$ ldconfig -v

doing this causes dispatch.fcgi to produce a 500 error, although it says:
/usr/local/lib:
libfcgi++.so.0 -> libfcgi++.so.0.0.0
libfcgi.so.0 -> libfcgi.so.0.0.0

Posted on November 23, 2005 at 5:34 am by yoav

i think that fastcgi is working now… doing the ldconfig -v thing i think was what i missed.

now i get these messages in fastcgi.crash.log:
[22/Nov/2005:19:49:52 :: 26136] starting
[22/Nov/2005:19:49:52 :: 26136] terminated gracefully

but this is showing up in server.log:
[Tue Nov 22 19:49:27 2005] [error] [client 127.0.0.1] FastCGI: incomplete headers (35 bytes) received from server “/home/virtual/site1/fst/var/www/html/public/dispatch.fcgi”

dispatch.cgi is working fine, so i don’t think it’s a mysql problem, or my script error.

any ideas or directions i should investigate?

thanks…

Posted on November 27, 2005 at 6:04 am by Arun Vijayan

I also had the rdoc/rdoc problem in FC4 while installing rails with gem

gem install rails
Attempting local installation of ‘rails’
Local gem file not found: rails*.gem
Attempting remote installation of ‘rails’
Install required dependency rake? [Yn] y
Install required dependency activesupport? [Yn] y
Install required dependency activerecord? [Yn] y
Install required dependency actionpack? [Yn] y
Install required dependency actionmailer? [Yn] y
Install required dependency actionwebservice? [Yn] y
Successfully installed rails-0.14.3
Successfully installed rake-0.6.2
Successfully installed activesupport-1.2.3
Successfully installed activerecord-1.13.0
Successfully installed actionpack-1.11.0
Successfully installed actionmailer-1.1.3
Successfully installed actionwebservice-0.9.3
/usr/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__’: No such file to load — rdoc/rdoc (LoadError)
from /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require’
from /usr/lib/site_ruby/1.8/rubygems/doc_manager.rb:43:in `generate_rdoc’
from /usr/lib/site_ruby/1.8/rubygems/gem_commands.rb:215:in `execute’
from /usr/lib/site_ruby/1.8/rubygems/gem_commands.rb:214:in `each’
from /usr/lib/site_ruby/1.8/rubygems/gem_commands.rb:214:in `execute’
from /usr/lib/site_ruby/1.8/rubygems/gem_commands.rb:153:in `each’
from /usr/lib/site_ruby/1.8/rubygems/gem_commands.rb:153:in `execute’
from /usr/lib/site_ruby/1.8/rubygems/command.rb:49:in `invoke’
from /usr/lib/site_ruby/1.8/rubygems/cmd_manager.rb:94:in `process_args’ from /usr/lib/site_ruby/1.8/rubygems/cmd_manager.rb:67:in `run’
from /usr/lib/site_ruby/1.8/rubygems/gem_runner.rb:13:in `run’
from /usr/bin/gem:17

i did a
sudo yum install irb ri
and reinstalled gem and rails. It went fine. I think in some of the distros (debian/Fedora)m you shouldnot install Ruby from tha package. Download latest version and install.

Posted on October 21, 2006 at 7:26 am by Felix

What a great installation record!
Thanks a lot!

Posted on October 23, 2007 at 12:10 am by Chris

I’ve gone through these instructions on a Red Hat/Ensim Pro box and everything looks to have installed correctly, but I’m getting a 500 error page when I switch to despatch.fcgi and I don’t thing that FastCGI is working properly. Don’t really know where to start looking for the problem … any help appreciated.

Leave a comment

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>