As I mentioned in my last post, RadRails 0.7.1 now supports Mongrel. So I decided to use Mongrel instead of Webrick for development on my notebook. But it was a bit tricky and took me a bit of googling to get it.
As Joe wrote in his post about installing Mongrel on MacOS X, I’ll describe how to install it on Ubuntu, assuming you already have Ruby and Ruby on Rails up and running.
Because Mongrel is partly written in C/C++ for more performance, you have to install the build-essential package. It will install all needed packages so that you can compile C/C++ applications.
sudo apt-get install build-essential
(You can also use the synaptic package manager to install it, if you prefer a GUI)
You also need the @ ruby1.8-dev@ package. When you try to install Mongrel without this installed, it will complain with this errormessage:
extconf.rb:1:in `require’: no such file to load — mkmf (LoadError)
from extconf.rb:1
Install the package with this command:
sudo apt-get install ruby1.8-dev
Then just use gem to install Mongrel:
sudo gem install mongrel —include-dependencies
Gem will ask you, which version of Mongrel you want to install. Choose the latest ruby verion.
Then you’ll see some output from the C/C++ compiler.
Ok, you’re done! Now you can start the server with mongrel_rails in your Railsapp directory.
NOTE: Even without the build-essential package installed, Mongrel will install and say that installation was successful. But when you try to start the server, you’ll get an error message like this:
** Starting Mongrel listening at 0.0.0.0:3000
/usr/local/ruby-1.8.4/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/
mongrel.rb:666:in `register’: undefined method `resolve’ for
nil:Mongrel::URIClassifier (NoMethodError)
UPDATE:
This tutorial also works with Ubuntu 6.10 Edgy Eft (tested with Knot 3)
I’ve added instructions to install the ruby1.8-dev package. This is also needed for installing Mongrel.
Hi Kommen,
I am newbie using Mongrel. We don’t need apache to run Mongrel?
Thanks,
ln
Hi,
no you don’t need Apache to use Mongrel. Mongrel is a standalone server. But most people use Mongrel and Apache (in production use) together:
Mongrel as the application server and Apache as the webserver.
For development, you won’t need Apache.
I found the answer on Mongrel website.
Thanks anyway.
ln
Thanks for the tips, i had forgotten the ruby dev package, and it was driving me mad!
Thanks, it worked on Feisty Fawn also.
thanks again, this works perfectly
Thank you; I installed Ubuntu Feisty Fawn server and these steps did the trick not just for Mongrel but for sudo gem install mysql. Back to Ruby.
Thank you J&K
Vish
On my machine, this worked but I needed to take it a couple steps further:
1. Go to the mongrel gem folder (/usr/local/ruby-1.8.4/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3 in this example) and run the setup.rb as root (sudo ruby setup.rb)
2. Add “#!/usr/bin/ruby1.8” to the top of the /usr/bin/mongrel_rails script if it doesn’t already exist. See http://www.forthecode.com/user/index/32 for more info.
Thanks for this…I had no idea why monrel wouldn’t install worked great!
Thanks guys, it saved me some trouble.
I’m starting a blog, and then I decided to post about this post.
If you don’t mind, I linked this post on my site: railslcones.com.
sudo gem install mongrel
Building native extensions. This could take a while…
ERROR: Error installing mongrel:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb install mongrel .include-dependencies
creating Makefile
make
cc -I. -I/usr/lib/ruby/1.8/i486-linux -I/usr/lib/ruby/1.8/i486-linux -I. -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -c fastthread.c
fastthread.c: In function âwait_condvarâ:
fastthread.c:626: warning: passing argument 1 of ârb_ensureâ from incompatible pointer type
cc -shared -o fastthread.so fastthread.o -L"." -L"/usr/lib" -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -lruby1.8 -lpthread -ldl -lcrypt -lm -lc
make install
/usr/bin/install -c -m 0755 fastthread.so /usr/lib/ruby/gems/1.8/gems/fastthread-1.0.1/lib
make: /usr/bin/install: Command not found
make: * [/usr/lib/ruby/gems/1.8/gems/fastthread-1.0.1/lib/fastthread.so] Error 127
Thx 4 thread, it gave me the hint!