Let's suppose I want to host 2 rails apps in the same server. I'd use RVM (installed as multiuser) and two different gemsets; suppose gemsetA for appA and gemsetB for appB.

What's the best way to manage this situation with Passenger module for apache2? Install and compile passenger apache2 module for each gemset or create another "passenger" gemset used only for this purpose?

Thank you

PS: I've already read this Multiple Rails sites using Passenger and VirtualHosts? but I think he is not using RVM or, at least, he is using only one gemset.

1 Answer 1


I'd first try installing passenger into the global gemset:

rvm use ree@global --default --passenger
rvm ree@global gem install passenger --version="${PASSENGER_VERSION}"
passenger-install-apache2-module --auto --apxs2-path $(which apxs2)
passenger-install-apache2-module --snippet >> /etc/apache2/conf.d/passenger.conf

Depending on your file permissions, you may or may not need to add the PassengerGroup www-data directive. Next, create your app gemsets:

rvm use ree@gemsetA --create
rvm ree@gemsetA gem install ${appA_gems}
rvm use ree@gemsetB --create
rvm ree@gemsetA gem install ${appB_gems}
# Must use .rvmrc files to change gemset per app
echo "rvm use ree@gemsetA" >> /path/to/appA/.rvmrc
echo "rvm use ree@gemsetB" >> /path/to/appB/.rvmrc

Finally, configure apache so each app gets it's own VirtualHost. Use a similar set of directives within the VirtualHost block:

    RackBaseURI /path/to/app(A|B)

    <Directory /path/to/app(A|B)>
        PassengerAppRoot /path/to/app(A|B)
        Options -MultiViews
        AllowOverride all
        Allow from all

You may need to play around with the paths for RackBaseURI and PassengerAppRoot depending on where you've installed your app, whether it's Rack based or otherwise, or how you've configured Apache. If in doubt, consult the Passenger Documentation.

If you've already tried this, and couldn't get it to work, and one of the apps cannot find it's gems... you may need to look into running Passenger Standalone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.