Using Python with Nginx via Passenger

Installing Passenger (Simple)

If you want to install the current version of Nginx (0.7.6) with default options, then follow the steps on this page, otherwise continue onto the next page to next page for more advanced configurations such as using a newer version (0.8.14 was my choice), as well as additional configurations for nginx.

Installing a default build is very quick and easy:

passenger-install-nginx-module

Which will bring up the following installation screen.

Nginx Simple Install 1

Above is the second screen (the first introduces you to Passenger and explains the process), here you are present with the option to have Passenger download, compile and install Nginx for you, usually at the current stable version (0.7.61 at the time of writing this). Choosing ‘1’ will start this process for you. If there are known dependencies not yet installed, Passenger can install them for you (such as PCRE).

Nginx Simple Install 2

Once the source has been downloaded by Passenger, it will prompt you on where you would like Nginx installed to, by default it is /opt/nginx.

Nginx Simple Install 3

Upon completion, Passenger informs you that the default Nginx configuration file has already been modified for Passenger.

Then you can then verify the version installed (you may need to add /opt/nginx/sbin to your PATH):

# nginx -V
nginx version: nginx/0.7.61
built by gcc 4.3.2 (Debian 4.3.2-1.1)
configure arguments: --prefix=/opt/nginx --with-pcre=/tmp/pcre-7.8
--add-module=/opt/ruby/lib/ruby/gems/1.9.1/gems/passenger-2.2.5/ext/nginx

The page following the next will show you how to set up a start/stop daemon with /etc/init.d as well as deploying your first Python (WSGI) application.

5 comments

  1. Hongli Lai says:

    Hi kbeezie, good writeup. 🙂 I just published a blog article about Phusion Passenger and Python today. Maybe you’d care to comment? http://izumi.plan99.net/blog/index.php/2009/11/21/phusion-passenger-for-python/

    “WeÂ’ll need to download and compile Ruby version 1.9.1 patch level 129. While this is not the latest, IÂ’ve had unconfirmed reports that anything newer than p129 is not fully compatible with Passenger.”

    This is correct. Later versions of 1.9.1 have bugs in the ‘tempfile’ library. These bugs have been fixed in Ruby’s SVN repository but so far there hasn’t been a 1.9.1 release containing the bug fixes.

    By the way, it’s not necessary to install Rails in order to use Phusion Passenger. Rails is only required if you deploy Rails apps.

  2. vanderkerkoff says:

    kbeezie, form some reason sudo is not finding ruby

    any ideas?

  3. kbeezie says:

    Without using sudo, try executing ruby -v to see if anything shows up at all, if not try ‘which ruby’. If nothing still shows up then either the PATH isn’t configured correctly to Ruby, or Ruby itself isn’t properly installed. ‘sudo’ itself doesn’t find commands per se, but is simply a way of saying ‘I want to run the following command as a super-user or root’.

  4. Jay States says:

    Hrm? Why, I’ll assuming that you’ve not seen the uwsgi project? This is much better for python/django/pylons – http://projects.unbit.it/uwsgi/

    Good Luck

  5. kbeezie says:

    Note the date of Nginx’s support for uwsgi and the date of said article.