Installing Passenger Enterprise + Nginx
from RubyGems (without RVM)
Table of contents
Before you begin: a note about Nginx
Before you begin, you should know that installing Passenger in its Nginx integration mode involves extending Nginx with code from Passenger. However, Nginx does not support loadable modules. This means that in order to install Passenger's Nginx integration mode, it is necessary to recompile Nginx from source. And that is exactly what we will do in this installation guide.
The fact that Nginx needs to be recompiled, has some implications:
Many users installed Nginx using their operating system's package manager (yum, apt-get, etc). This Nginx is usually located in /usr/sbin/nginx, with configuration file /etc/nginx/nginx.conf. However, if you install Nginx from source, then you will end up with another Nginx installation (that has Passenger enabled) that is located somewhere else. This other Nginx installation does not look for its /etc/nginx/nginx.conf, but somewhere else.
Some people get confused by having two Nginx installations and end up editing the wrong config file. To avoid confusion, this guide will recommend you to uninstall the OS-installed Nginx before proceeding.
Init scripts, e.g.
service nginx restart, are not provided by the default Nginx source code. Init scripts are actually extensions provided by the operating system's Nginx package. If you install Nginx from source, then you can't use init scripts to control Nginx anymore. Instead, you will use more generic operating system primitives to control Nginx, such as PID files and signals. Don't worry, this installation guide will teach you.
If you do not like having to recompile Nginx then there are several alternatives you can choose:
- Use the Phusion Passenger APT repository (for Debian, Ubuntu) or the YUM repository (RPMs for Red Hat, CentOS) to install Passenger and Nginx. Through our APT/YUM repository, we provide a Passenger-enabled Nginx package that uses the same structure as the Nginx package provided by the OS. This means that you will be able to use the
servicescript, your config files are at places where you expect them, etc.
- Consider using Passenger Standalone in a reverse proxy configuration to Nginx. Passenger Standalone + reverse proxy is fully supported and supports the same features as Passenger's Nginx integration mode.
If you understand this and choose to use Passenger with its Nginx integration mode, then read on. :-)
Step 1: download and install your license key
Before you can install Passenger Enterprise, you need to download and install your license key. This is a regular file that you need to copy to your production server.
Please login to the Passenger Enterprise Customer Area.
Click on the Install button in the Customer Area.
Click on the button to download the license key.
The license key will be downloaded to your local computer. Copy this license key file to your production server, for example using
local-computer$ cd /path-to-your-local-computer-download-folder local-computer$ scp passenger-enterprise-license firstname.lastname@example.org:
adminuser with the name of an account with administrator privileges or sudo privileges.
Finally, login to your production server and save the file as
local-computer$ ssh email@example.com production-server$ sudo mv passenger-enterprise-license /etc/passenger-enterprise-license production-server$ chmod 644 /etc/passenger-enterprise-license
Step 2: obtain your download token
Your download token is needed in order to install Passenger Enterprise. In the Customer Area, find your download token and copy it to your clipboard.
Step 3: install gem
Add the Passenger Enterprise gem server to your RubyGems source list:
$ unset HISTFILE $ gem source --add https://download:YOUR_DOWNLOAD_TOKEN@www.phusionpassenger.com/enterprise_gems/
YOUR_DOWNLOAD_TOKEN with the one you found in the Customer Area. And notice the trailing slash in the URL! It is very important.
Finally, install Passenger Enterprise gem with:
$ gem install passenger-enterprise-server --no-rdoc --no-ri
--no-rdoc --no-ri argument isn't really necessary, but it makes installation faster by skipping generation of API documentation.
Step 4 (optional): uninstall the OS-installed Nginx
As explained earlier in the introductory notes, you are about to install a new Nginx installation from source. If you already installed Nginx before, using the operating system's package manager, then we recommend that you uninstall that in order to avoid possible confusion caused by having multiple parallel Nginx installations. Of course, you don't have to remove the OS-installed version as long as you know what you're doing.
Here are some examples of how you can uninstall the OS-installed version:
sudo apt-get purge nginx nginx-full nginx-light nginx-naxsi nginx-common sudo rm -rf /etc/nginx
|Red Hat, CentOS, Fedora, Scientific Linux, Amazon Linux||
sudo yum remove nginx sudo rm -rf /etc/nginx
Step 5: run the Passenger Nginx module installer
Run the Passenger Nginx module installer and follow the on-screen instructions:
Step 6: validate installation
After installation, please validate the install by running
sudo passenger-config validate-install. For example:
$ sudo passenger-config validate-install * Checking whether this Phusion Passenger install is in PATH... ✓ * Checking whether there are no other Phusion Passenger installations... ✓
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 passenger-memory-stats. You should see Nginx processes as well as Passenger processes. For example:
$ sudo passenger-memory-stats Version: 5.0.8 Date : 2015-05-28 08:46:20 +0200 ... ---------- Nginx processes ---------- PID PPID VMSize Private Name ------------------------------------- 12443 4814 60.8 MB 0.2 MB nginx: master process /usr/sbin/nginx 12538 12443 64.9 MB 5.0 MB nginx: worker process ### Processes: 3 ### Total private dirty RSS: 5.56 MB ----- Passenger processes ------ PID VMSize Private Name -------------------------------- 12517 83.2 MB 0.6 MB PassengerAgent watchdog 12520 266.0 MB 3.4 MB PassengerAgent server 12531 149.5 MB 1.4 MB PassengerAgent logger ...
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.
As explained earlier in the introductory notes, you can't use an init script like
service nginx restart. This section teaches you how to control and how to work with the Nginx you installed.
Remember that at some point,
passenger-install-nginx-module asked you where to install Nginx to, and asked you for a "prefix", right? The prefix is the directory in which this new Nginx is installed. By default, the installer picks the directory
/opt/nginx. In this section we will assume that you installed to the default prefix directory. If you specified a different prefix, simply substitute /opt/nginx with the actual directory.
Nginx's configuration files are then located in
/opt/nginx/conf. Its log files are located in
You can start Nginx by running:
$ sudo /opt/nginx/sbin/nginx
Shutting down Nginx
You can shut down Nginx by killing its PID with the
kill command. To find out what Nginx's PID is, use the
ps command. For example:
$ ps auxw | grep nginx root 25817 0.0 0.1 43248 1172 ? S Jan01 0:00 nginx: master process /opt/nginx/sbin/nginx www-data 25818 0.0 0.3 44240 3484 ? S Jan01 0:02 nginx: worker process
Here we see that the Nginx master process has PID 25817 (you can ignore the worker process), so we run:
$ sudo kill 25817
Having to perform two steps is a bit cumbersome. Luckily, there is an easier way to do this. By default, Nginx creates a PID file in
/opt/nginx/logs/nginx.pid. This PID file contains Nginx's current PID. So we can use a single command to shutdown Nginx:
$ sudo kill $(cat /opt/nginx/logs/nginx.pid)
Restarting Nginx is the same as shutting down Nginx, and starting it again. For example:
$ sudo kill $(cat /opt/nginx/logs/nginx.pid) $ sudo /opt/nginx/sbin/nginx
How do I install Nginx with additional modules?
You can install Passenger as a normal Nginx module.
The installer is interactive. How do I install in an automated, non-interactive manner?
Please refer to Non-interactive, automatic, headless installs or upgrades.
Some of the dependent libraries are installed in non-standard locations. How do I allow the compiler to find them?
Please refer to Customizing the compilation process.
How do I pass additional flags to the compiler?
Please refer to Customizing the compilation process.