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
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.
Our apologies to Windows users. Passenger doesn't support Windows. We require a Unix-like operating system.
Limited package support for non-LTS Ubuntu versions
You have selected a non-Long Term Support version of Ubuntu. We only provide .deb packages for non-LTS Ubuntu versions until the next Ubuntu version comes out. Ubuntu versions come out every 6 months.
So when the next Ubuntu version is released, you must upgrade your system to that new Ubuntu version. Otherwise you won't receive Passenger updates in the form of .deb packages from us anymore.
You can install Passenger through APT:
# Install our PGP key and add HTTPS support for APT
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates
# Add our APT repository
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update
# Install Passenger
sudo apt-get install -y passenger
After installation, please validate the install by running passenger-config validate-install. For example:
$ passenger-config validate-install
* Checking whether this Phusion Passenger install is in PATH... ✓
* Checking whether there are no other Phusion Passenger installations... ✓
If you are using cPanel/WHM, note that it uses EasyApache whereas Passenger RPMs are designed for the official distro Apache. In this setup the gem installation method is likely a better fit, and you should ensure you have the correct apache tools installed: yum remove httpd-tools && yum install ea-apache24-devel. You will also likely need to disable SELinux when using the Passenger gem.
Notes about SELinux on CentOS 7
If you experience dependency errors related to selinux-policy while installing Passenger first try yum clean all && yum update, and if that doesn't resolve the issue, try enabling the CR repo: sudo yum update && sudo yum-config-manager --enable cr.
Notes about SELinux on Red Hat 6 and CentOS 6
Passenger versions prior to 5.1 require kernel >= 2.6.39 if you are installing on Red Hat 6 or CentOS 6 with SELinux set to enforcing mode.
The pre 5.1 Passenger versions can also be installed without upgrading the kernel if you completely disable SELinux. Edit /etc/selinux/config, set SELINUX=disabled and reboot. Note that merely setting SELinux to permissive mode is not enough.
This issue does not apply to Red Hat >= 7 and CentOS >= 7, because these OS versions supply recent enough kernel versions.
You can install Passenger through YUM. But first you need to enable EPEL. The instructions differ depending on whether you are on Red Hat or CentOS. The second step is only necessary on Red Hat.
step 2 (rhel only):
enable the 'optional' repository
enable the optional repository (rhel-67-server-optional-rpms). this can be done by enabling the rhel optional subchannel for rhn-classic. for certificate-based subscriptions see red hat subscription management guide.
Repair Potential System Issues
# Ensure curl and nss/openssl are sufficiently up-to-date to talk to the repo
sudo yum update -y
date
# if the output of date is wrong, please follow these instructions to install ntp
sudo yum install -y ntp
sudo chkconfig ntpd on
sudo ntpdate pool.ntp.org
sudo service ntpd start
After installation, please validate the install by running passenger-config validate-install. For example:
$ passenger-config validate-install
* Checking whether this Phusion Passenger install is in PATH... ✓
* Checking whether there are no other Phusion Passenger installations... ✓
After installation, please validate the install by running passenger-config validate-install. For example:
$ passenger-config validate-install
* Checking whether this Phusion Passenger install is in PATH... ✓
* Checking whether there are no other Phusion Passenger installations... ✓
Extract the tarball to some place permanent. Replace X.X.X with the Passenger version, and /somewhere-permanent with an actual directory path.
$ tar -xzvf passenger-X.X.X.tar.gz -C /somewhere-permanent
Step 2: install Ruby
Passenger supports multiple languages and its core is written in C++, but its installer and administration tools are written in Ruby, so you must install Ruby.
Even though Ruby is required, Ruby will normally not be loaded during normal operation unless you deploy a Ruby web application on Passenger. Passenger's dependency on Ruby is very minimal. See Lightweight Ruby dependency for details.
Again, replace X.X.X with the Passenger version, and /somewhere-permanent with an actual directory path.
When you're done, restart all your shells so that your new PATH takes effect.
Make sure your bashrc is actually included by your bash profile, which might not be the case if you created the user with useradd instead of adduser for example.
Step 4: validate installation
After installation, please validate the install by running passenger-config validate-install. For example:
$ passenger-config validate-install
* Checking whether this Phusion Passenger install is in PATH... ✓
* Checking whether there are no other Phusion Passenger installations... ✓
Preparing the example application
In this tutorial we will use an example Meteor application. The builtin Meteor leaderboard example is a good one.
$ cd ~
$ meteor create --example leaderboard
$ cd leaderboard
Running the server
You normally run your app like this when in development mode, right?
$ meteor run
It's similar with Passenger. Instead of meteor run, you run your app with passenger start:
$ passenger start
======= Phusion Passenger Standalone web server started =======
PID file: /Users/phusion/leaderboard/passenger.3000.pid
Log file: /Users/phusion/leaderboard/passenger.3000.log
Environment: development
Accessible via: http://0.0.0.0:3000/ 1
You can stop Phusion Passenger Standalone by pressing Ctrl-C.
===============================================================
App 85125 stdout: [[[[[ ~/leaderboard ]]]]] 2
App 85125 stdout:
App 85125 stdout: => Started proxy.
App 85125 stdout: => Started MongoDB.
App 85125 stdout: => Started your app.
App 85125 stdout:
App 85125 stdout: => App running at: http://localhost:9822/ 3
We see a couple of things here:
Passenger reports that it has started a server, which is accessible via http://0.0.0.0:3000/. It also tells you where it has placed its PID file and log file.
Internally, Passenger runs your Meteor app by invoking the command meteor run. You can see the output of that command in the lines that are marked with "App xxx stdout". The xxx is the PID of the meteor run command.
meteor run starts its own server at http://localhost:9822/. But that is not the URL you should visit. Passenger listens on its own port, manages Meteor, and forwards requests to Meteor through the address http://localhost:9822/. So you should ignore this line.
So Passenger is now serving your app on http://0.0.0.0:3000/. 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...
Stopping the server
If you stop Passenger, Passenger will stop your Meteor app.
There are two ways to stop the server. The first is by pressing Ctrl-C in the terminal.