Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Phusion Passenger, MySQL and Rails to play nicely in production

I've written a rails app that's been running fine for a while without a database. Now, I'm dropping the registration database into the mix. It's not working in production. Everything works fine, of course, on my Mac.

Here's the production environment: - Ubuntu Hardy - Phusion Passenger - Rails 2.3.2

MySQL on the machine is running fine.

I have the database.yml file with the correct information. I can run the migrations with no problems:

rake db:migrate RAILS_ENV=production

The database is being correctly updated.

So, I hit tmp/restart and hit the site. I got the 500 error, but nothing was written to the production log (very odd). So, I checked the apache log, and I got this message:

!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.

I have installed the MySQL gem (version 2.7). I'm still getting this error.

When I change the production database configuration to point to a dummy sqlite database, everything works fine. When I change it back to the MySQL configuration, I get the same error message.

I'm entirely out of ideas, and I wish that it would just work. I'm pulling my hair out, and I greatly appreciate any help you can provide. I've included everything I could think of, but please let me know if any more information would be useful.

Thanks!

Jason

like image 571
Jason Butler Avatar asked Dec 13 '22 04:12

Jason Butler


2 Answers

Figured it out. Woo Hoo!

Summary: Ruby Enterprise Edition (update, thanks Hongli!) has its own set of gems. Even though I was updating the gem, it wasn't the one that Passenger was reading.

Here's how I figured that out:

>> /usr$ whereis gem

gem: /usr/bin/gem /usr/bin/gem1.8 /opt/ruby-enterprise-1.8.6-20090201/bin/gem

>> /usr$ cd /opt/ruby-enterprise-1.8.6-20090201/bin/

>> /opt/ruby-enterprise-1.8.6-20090201/bin$ ls -l

total 2624
-rwxr-xr-x 1 root root    3907 2009-03-26 14:47 erb
-rwxr-xr-x 1 root root     813 2009-03-26 14:47 gem
-rwxr-xr-x 1 root root     349 2009-03-26 14:47 irb
-rwxr-xr-x 1 root root     386 2009-03-26 14:47 passenger-config
-rwxr-xr-x 1 root root     402 2009-03-26 14:47 passenger-install-apache2-module
-rwxr-xr-x 1 root root     396 2009-03-26 14:47 passenger-make-enterprisey
-rwxr-xr-x 1 root root     392 2009-03-26 14:47 passenger-memory-stats
-rwxr-xr-x 1 root root     392 2009-03-26 14:47 passenger-spawn-server
-rwxr-xr-x 1 root root     386 2009-03-26 14:47 passenger-status
-rwxr-xr-x 1 root root     391 2009-03-26 14:47 passenger-stress-test
-rwxr-xr-x 1 root root     366 2009-03-26 14:47 rackup
-rwxr-xr-x 1 root root     367 2009-03-26 14:47 rails
-rwxr-xr-x 1 root root     364 2009-03-26 14:47 rake
-rwxr-xr-x 1 root root    1560 2009-03-26 14:47 rdoc
-rwxr-xr-x 1 root root      64 2009-03-26 14:46 ree-version
-rwxr-xr-x 1 root root    1516 2009-03-26 14:47 ri
-rwxr-xr-x 1 root root 2609905 2009-03-26 14:46 ruby
-rwxr-xr-x 1 root root     178 2009-03-26 14:47 testrb

>> /opt/ruby-enterprise-1.8.6-20090201/bin$ ./gem list

*** LOCAL GEMS ***

actionmailer (2.3.2)
actionpack (2.3.2)
activerecord (2.3.2)
activeresource (2.3.2)
activesupport (2.3.2)
fastthread (1.0.5)
passenger (2.1.2)
postgres (0.7.9.2008.01.28)
rack (0.9.1)
rails (2.3.2)
rake (0.8.4)
sqlite3-ruby (1.2.4)

>> /opt/ruby-enterprise-1.8.6-20090201/bin$ ./gem install mysql

Building native extensions.  This could take a while...
Successfully installed mysql-2.7
1 gem installed

Then, I restarted the instance, and it worked.

like image 151
Jason Butler Avatar answered Jan 29 '23 07:01

Jason Butler


@Jason Butler: I do not have enough reputation to comment so I'll post it as an answer instead.

It's not Phusion Passenger that has its own set of gems, it's Ruby Enterprise Edition. This is in fact documented, and its reason explained: http://www.rubyenterpriseedition.com/documentation.html#_how_ree_installs_itself_into_the_system

like image 40
Hongli Avatar answered Jan 29 '23 07:01

Hongli