How to Setup Nginx With Passenger on AWS Production Server

This blog post describes the steps for the installation of Passenger with Nginx through the Ubuntu 16.04 LTS operating system following APT method.

Setup Nginx With Passenger on AWS Production Server
Setup Nginx With Passenger on AWS Production Server


You need to install and configure nginx with passenger on AWS production serve before you deploy your application on the production server.

Passenger provides a lot of customization and features options. Passenger some features are used for improving the application’s performance characteristics. Some of customization influence application or connection handling behavior etc. Two configuration options for Passenger are needed to be setup in Nginx, named as passenger_enabled and passenger_root. Passenger and Nginx installation process will setup both of these options automatically.

In today’s blog post article, I’m going to cover some of the essential configuration steps for the installation of Passenger with Nginx on the Ubuntu operating system following APT method. You will be able to deploy and administer applications written in Node.js, Python, and Ruby after reading and following this article.

Table of contents:

  • Install Nginx and Passenger packages
  • Enable the Passenger Nginx module and restart Nginx
  • Validate installations
  • System and passenger updates
  • Conclusion

1. Install Nginx and Passenger packages:

These commands will install Passenger and Nginx through Phusion’s APT repository. If you already had Nginx installed then these commands will upgrade Nginx to Phusion’s version with Passenger compiled in.

# Install Ubuntu PGP key and add HTTPS support for APT
sudo apt-get install -y dirmngr gnupg
sudo apt-key adv --keyserver hkp:// --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates

# Add and update phusionpassenger APT repository
sudo sh -c 'echo deb xenial main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update

# Install Passenger with Nginx
sudo apt-get install -y nginx-extras passenger

2. Enable the Passenger Nginx module and restart Nginx:

Edit /etc/nginx/nginx.conf and uncomment include /etc/nginx/passenger.conf;. For example, you may see this:

# include /etc/nginx/passenger.conf;

Remove the ‘#’ characters, like this:

include /etc/nginx/passenger.conf;

If you don’t see a commented version of include /etc/nginx/passenger.conf; inside nginx.conf, then you need to insert it yourself. Insert it into /etc/nginx/nginx.conf inside the http block.

http {
    include /etc/nginx/passenger.conf;

When you are finished with this step, restart Nginx:

$ sudo service nginx restart

3. Validate installations:

After installation, please validate the install in terminal by running command sudo /usr/bin/passenger-config validate-install:

sudo /usr/bin/passenger-config validate-install

All checks should pass. If any of the checks do not pass, please follow the suggestions on screen.

Finally, check whether Nginx has started the Passenger core processes. Run sudo /usr/sbin/passenger-memory-stats. You should see Nginx processes as well as Passenger processes. For example like below:

sudo /usr/sbin/passenger-memory-stats

If you do not see any Nginx processes or Passenger processes, then you probably have some kind of installation problem or configuration problem. Please refer to the troubleshooting guide.

4. System and passenger updates:

Nginx updates, Passenger updates and system updates are delivered through the APT package manager regularly. You should run the following command regularly to keep them up to date:

sudo apt-get update
sudo apt-get upgrade

You do not need to restart Nginx or Passenger after an update, and you also do not need to modify any configuration files after an update. That is all taken care of automatically for you by APT.


Congratulations, you have successfully installed and configured nginx With passenger on AWS production server for your web application. Please take a look at the various guides in the passenger library for fully mastering passenger application server. You may be particularly interested in the automating deployment guide of your ruby application through Capistrano, which teaches you how to automatically deploy future application updates without so much manual work. Now you are ready to deploy your web application on the aws production instance.


You may find the following relevant blog posts: