Multiple Rubies on one server

I had the ‘joy’ of upgrading to Rails3 recently. The Rails application wasn’t the problem, but making it work alongside another Rails 2.3 application on my server was tough and gave me many headaches. Having multiple ruby- and rails versions proofed to be tricky. There is documentation, but I just couldn’t get my head around it, so I just want to sum up some of my pitfalls and give pointers.

Few words about my setup. I have a Debian server running apache2 with Passenger 3. My system Ruby is 1.8 and my goal was to have one application run on Ruby 1.8.2 (and Rails 2.3) and one on 1.9.2 (and Rails 3.0)

RVM

Ruby Version Management is cool for development and also nice for running multiple environments of Ruby. In my case one with the old Ruby 1.8.7 and a new one for Ruby 1.9.2. You can use rvm on your server, however it does not work as smooth with Passenger as you’d hope. RVM has some very good documentation, but the bit about Passenger failed to tell me what I need. In essence my misconception was, that you’d tell the system-wide Passenger configured in apache to switch to the rvm gemset. It tries to do this, but fails, as it’s still executed by the system-ruby-binary, not the ruby-binary within the rvm set. This means, you have just one rvm gemset from which you can run your app via Passenger within apache. For more Rails applications with different rvm gemset, you need to start them as Passenger Standalone and add them as ProxyPass in the apache2 virtualhosts. This is well described in the Phusion Passenger blog and untangled the knot in my brain!

ProxyPass

So I set up my Rails app as Passenger standalone as described in the article above. I used RAILS_ENV=production to pass the correct environment:

I got a few apache errors as my ProxyPass was not configured correctly. Nothing a good search engine and a look at /var/log/apache2/error.log couldn’t help.

With one exception. My resources, stylesheets, pictures weren’t loaded. The log gave this message:

proxy: DNS lookup failure for: localhost:3000stylesheets returned by /stylesheets/screen.css

This one was nasty, and there weren’t many helpful answers on the net, probably because the solution is so simple when you know whats wrong. My hint: It’s a missing / in the virtualhosts config of the ProxyPass.

Das Lese-Oktett #27

Nach langer Zeit mal wieder ein Lese-Oktett

The Day After: Ein Tag nach dem Geld

Massengrab in New York – Insel der einsamen Toten

Gesellschaft

Back from the future – Messungen unterstützen These, dass die Zukunft Auswirkungen auf die Vergangenheit haben kann

Gescheiterte Integration der Konservativen

Die Legende vom Salzstock – Etwas Aufklärung wo die Castoren eigentlich stehen

Mal was über Pornos

Wie Hitler Deutscher wurde

Technologie

Commandlines are alive and kicking

Neue Trendsportart: Extreme Technikpaternalisting

The things he carried – Über die Farce der Airport-Security

DIY Laser- Microscope

Filmtipp:

Beda Stadler – Über Gentechnik und Vernunft

Kubrik, Nixon und der Mann im Mond

Umfragen-Fail

Über die Uni-Maillinglist kommen gelegentlich Umfragen von Studenten für ihre Abschlussarbeiten. An den Umfragen kann man sehr schön sehen wie Umfragen funktionieren oder nicht funktionieren sollten.

Aktuelles Beispiel ist eine Umfrage, die über umweltfreundliche Elektrotechnik ist. Darunter sind folgende  Fragen für die man von 0-100% seine Zustimmung geben kann:

  • “Ich möchte den folgenden Generationen eine gesunde Welt hinterlassen. “
  • “Ich möchte ein umweltfreundliches Auto.”

Ich frage mich ja, ob ich der Einzige sein werde, der eine gesunde Umwelt hinterlassen und kein umweltfreundliches Auto möchte. Angst macht mir noch vielmehr, das Leute diese Kombination nicht in Ermangelung an eine sinnvolle Fragestellung ankreuzen.