Quickstart: Ruby + Phusion Passenger

This 5 minute tutorial teaches you to start your application in a Phusion Passenger server, in development mode. Feel what Passenger is and how it works.

Are you looking to deploy your app to production with Passenger, maybe in combination with Nginx or Apache? Take a look at the deployment tutorial.

Table of contents

  1. Loading...

What is Passenger?

Passenger is an open source web application server. It handles HTTP requests, manages processes and resources, and enables administration, monitoring and problem diagnosis.

Passenger is very easy to use, makes deploying in production much easier and is scalable. If you aren't already familiar with the benefits, you can learn more about them.

This tutorial doesn't go very deep into Passenger's concepts. Instead, it serves to get you started as quickly as possible. When you're done with this tutorial, we'll explain the concepts in more detail.

Preparing the example application

In this tutorial we will use an example "hello world" application. Clone the one you like.

Ruby on Rails example:

$ git clone https://github.com/phusion/passenger-ruby-rails-demo.git
$ cd passenger-ruby-rails-demo

Sinatra example:

$ git clone https://github.com/phusion/passenger-ruby-sinatra-demo.git
$ cd passenger-ruby-sinatra-demo

Updating your gem bundle

Open your app's Gemfile and add "passenger":

gem "passenger", ">= 5.0.25", require: "phusion_passenger/rack_handler"

Now open a terminal, go to your application's directory and run bundle install to install your gem bundle:

$ cd /path-to-your-app
$ bundle install
...
Installing passenger x.x.x
...
Your bundle is complete!

Running the server

You are now ready to run the Passenger server. Run:

$ bundle exec passenger start
======= Phusion Passenger Standalone web server started =======
PID file: /Users/phusion/myapp/tmp/pids/passenger.3000.pid
Log file: /Users/phusion/myapp/log/passenger.3000.log
Environment: development
Accessible via: http://0.0.0.0:3000/

You can stop Phusion Passenger Standalone by pressing Ctrl-C.
===============================================================

As you can see in the output, Passenger is now serving your app on http://0.0.0.0:3000/. So if you go to that URL, you will should see your application:

$ curl http://0.0.0.0:3000/
...your app's front page HTML...

You can also use "bundle exec rails server"

If you use Rails, then you can also run bundle exec rails server. As long as you have the above Gemfile entry, that command will start a Passenger-based server.

Logs

Passenger prints its own logs not only to the terminal, but also to a log file. During startup, Passenger tells you what log file it used. This is typically log/passenger.XXXX.log.

There are also the application logs, such as log/development.log and log/production.log. These logs are completely separate from Passenger's own logs. If you use Rails, then Passenger will also print your application logs to the terminal, but it will not print them into Passenger's log file.

If you do not use Rails then Passenger may not print your logs to the terminal at all. In that case it is up to you to manually view those log files, e.g. with the Unix tail tool.

Stopping the server

There are two ways to stop the server. The first is by pressing Ctrl-C in the terminal.

$ bundle exec passenger start
...
(press Ctrl-C here)
Stopping web server... done!

The second way is by starting a seperate terminal, changing the working directory to your application, and running bundle exec passenger stop:

$ cd /path-to-your-app
$ bundle exec passenger stop

Conclusion

Achievement unlocked. Image taken from https://openclipart.org/detail/60109/award-symbol-by-sheikh_tuhin

Congratulations! You've passed this tutorial and seen Passenger in action. You can find the end result of this tutorial in the example application's git repository's end_result branch:

Next step

You may now be interested in follow-up tutorials.

Basics

Learn what Passenger is, how it fits in the stack, its fundamental concepts and its basic usage. Focuses mainly on development rather than production.

Read this
Deployment

Learn how easy it is to setup a server and how to deploy your app to production. No worries, we walk you through from the beginning to the end.

Read this

...or go back to the Library index.