---
title: "Using multiple versions with Passenger"
date: "2015-02-13"
category: "python"
slug: "using-multiple-versions-passenger"
---

## Overview

[Passenger](https://www.phusionpassenger.com/) provides a polyglot launcher for managing Node.js, [[setting-rails-passenger]], and Python processes. Combined with [[changing-python-versions]], you can run multiple Python applications using different interpreters with a single [[htaccess-guide]] directive.

These steps are only necessary when using a non-default Python version. If the default version works for your needs, no changes are required.

## Usage

First, create a Passenger-compatible directory structure using what you learned from [[changing-python-versions]]:

cd /var/www
mkdir -p mypyapp/{public,tmp}
cd mypyapp

Assign a Python interpreter (e.g. 3.3.5):

pyenv local 3.3.5

Tell Passenger to use the pyenv shim by adding the following directive to `public/.htaccess`:

echo "PassengerPython /.socket/python/shims/python" > /var/www/mypyapp/public/.htaccess

## Performance Note

Using pyenv's shim system with Passenger is slower than accessing the Python binary directly, because multiple shell subprocesses are launched to resolve the correct interpreter. If performance is critical, consider adapting your application to the FastCGI specification for background persistence.

## See Also

- Concurrent [Python 2](http://py2.futz.net/) and [Python 3](http://py3.futz.net/) implementations on Sol (a v6 platform)
