Using passenger to run your rails applications when developing

18 Sep 2009, by Michael Cindrić

If your like me and sick of having to run ./script/server every time you want to start your rails app using passenger locally is for you then. First thing is to install passenger like so

sudo gem install passenger

Then you need to install the apache module for passenger.

sudo passenger-install-apache2-module

Now once you do this you will be told to all the following lines to your httpd.conf file in apache. Now you can just add these lines no problems but l like to have it in its own conf file and since apache will also load all conf files in /etc/apache2/other/ directory just create a passenger.conf file and add those lines in. Now these lines are different depending on how you installed ruby. I installed it in user/local keeping the orginal ruby version that ships with mac clean so mine looks like so

LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.5/ext/apache2/
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.5
PassengerRuby /usr/local/bin/ruby

To create the new passenger.conf file just run the below command assuming you have textmate installed.

mate /etc/apache2/other/passenger.conf

Once you have cut and pasted those lines in save it and close the file. You then need to download the passenger preference pane. Here is a link to the latest build passenger-preference-pane1.3. Download and install then fire it up.

Passenger preference pane

Now unlock it if need be and click on the + button to add a new site. A window will pop up and now just select the root of your rails app and click "open". You can now change the address if need be but just defaults to (rails_app_name).local. Hit apply and your good to go.

So go back to your browser and type in that address and it will fire up and your up and running. Now you wont see the log like you are used to since your not running webrick etc but all you have to do is tail the development log by going to the root dir of your application in terminal and typing the following

 tail -f log/development.log

And that's it. You will need to restart passenger if you change the environment.rb file but thats simple enough via the preference pane. So no more ./script/server yay

Cookies help us deliver our services. By using our services, you agree to our use of cookies.