Phusion Passenger on OS X

Setting up Phusion Passenger on OS X with GCC 4.8 installed By Yihang Ho

I was introduced Phusion Passenger long time ago when I started learning Ruby on Rails. It is a web server and application server that is quite popular. Its website boasts that installation is simple and there are only two steps involve. The installation is indeed easy and simple, if you have are using all the default stuff that come with your OS.

A little bit of background - I am running OS X 10.8.4 (updating to 10.8.5 at the time of writing), Ruby 2.0.0p247 built by RVM and, most importantly, GCC/G++ 4.8.1. Long story short, GCC/G++ 4.8.1 is causing problem - disable it and use the default GCC/G++ provided by Apple. For me, the default version is 4.2.1.

What I have done before is to follow the installation guide:

  • gem install passenger
  • passenger-install-apache2-module
  • At the end of the compilation, I was asked to add some lines to the configuration file of Apache. So I copied and pasted all those lines to the very end of /etc/apache2/httpd.conf.
  • Also, there is a suggested snippet to set up virtual host for rail projects. I did that to, and the virtual host serves a dummy application just created by rails new.
  • sudo apachectl restart
  • Visit the virtual host. Browser complains that 'Oops! Google Chrome could not connect to...' All the existing virtual hosts that were working are not working anymore.
  • Next I tried httpd -t. This is the output:

    httpd: Syntax error on line 513 of /private/etc/apache2/httpd.conf: Cannot load /Users/yihangho/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.17/buildout/apache2/modpassenger.so into server: dlopen(/Users/yihangho/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.17/buildout/apache2/modpassenger.so, 10): Symbol not found: ZNSt3tr18detail12_primelistE\n Referenced from: /Users/yihangho/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.17/buildout/apache2/modpassenger.so\n Expected in: flat namespace\n in /Users/yihangho/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.17/buildout/apache2/modpassenger.so

I've been Googling a lot and nobody else seems to have this problem. Until I tried to use all the default tools - this includes GCC/G++. So what I did was to (temporarily) remove /usr/local/bin from my PATH variable (most likely they are set in ~/.bashrc, ~/bash_profile and/or /etc/paths), which effectively temporarily remove ALL homebrew installed application. I have to admit that the proper way is to brew unlink gcc48 then brew link gcc48 at the end. After you have done this, just trigger passenger-install-apache2-module and all should be good. smile