How can I tell Phusion Passenger which python to use?

phusion passenger python 3
what is passenger
mod_passenger
dreamhost passenger
nginx - passenger
passenger deploy
passenger-config
passenger python flask demo

I'm using Phusion Passenger with a ruby app and I'd also like to set it up to work with an django appengine app I'm working on.

Googling for "passenger_wsgi.py" I was able to get the following very simple non-django app working on passenger:

passenger_wsgi.py:

def application(environ, start_response):
   response_headers = [('Content-type','text/plain')]
   start_response('200 OK', response_headers)
   return ['Hello World!\n']

However, if I add the line import django.core.handlers.wsgi into the mix, I get 'An error occurred importing your passenger_wsgi.py'. By printing out the sys.path I've discovered that at least part of the reason is because Passenger is using the wrong python installation on my machine.

How can I configure Passenger (on apache) to use /opt/local/bin/python2.5 instead of the system default python?

I discovered that if I changed the hashbang at the first line of passenger's request_handler.py file to #!/opt/local/bin/python2.5, passenger used the correct python. But surely there must be a better way than modifying passenger's distribution?

Passenger + Python basics, In this tutorial we will use an example "hello world" application, written in Flask: Many Python web frameworks have a builtin web server that is activated by running the As you can see in the output, Passenger is now serving your app on  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.

You can specify the python interpreter via the PassengerPython variable in the server config, virtual host, directory, or .htaccess file.

apache: PassengerPython

nginx: passenger_python

standalone: --python

Quickstart: Python + Phusion Passenger, The PID file contains the process ID of the Passenger instance, and allows other passenger subcommands to know which process to operate on. Passenger has  Phusion 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.

One trick is to include a line like this in your passenger_wsgi.py file:

if sys.version < "2.4":  
     os.execl("/usr/bin/python2.4", "python2.4", *sys.argv)

or

INTERP = "/usr/local/bin/python"  
    if sys.executable != INTERP:  
        os.execl(INTERP, INTERP, *sys.argv)

Each of these basically tells the environment to use your preferred python.

'passenger' command - Passenger + Python basics, <VirtualHost *:80> ServerName yourserver.com # Tell Apache and Passenger where your app's Tell Passenger that your app is a Python app PassengerAppType wsgi PassengerStartupFile For example, suppose that you already have a virtual host for the application /websites/phusion : Which one should I use? Deploying a Python application on Passenger + Apache. This guide teaches you how you can deploy your app to a server. This guide assumes that you have already done the following, and that you know how to do them: Passenger and Apache are already installed on the server. You have already transferred the application's code to the server.

Deploying a Python application - Apache, You should also check that file to see whether your application So if you're using Rails, please be sure to check  This script will look at which language was chosen by the user and then redirect to that directory. So that's where you'll find the Python file you want to edit. Open the Python directory and edit the index.html.md.erb file. Now sometimes you'll open the index.html.md.erb file and you might find that the only content is a Middleman partial.

Troubleshooting - Apache and Python - Passenger Library, for Python developers You can use the passenger-config restart-app command to restart an If the menu doesn't display correctly, press '!' ‣ /Users/phusion/​testapp/public You have tell Passenger to restart the application like this: Copy. Deploying a Python app on a Linux/Unix production server with Passenger in Apache mode on Red Hat 7 / CentOS 7 (with RPM) This page describes the deployment of a Python app, assuming that Passenger was installed through the following operating system configuration or installation method: Red Hat 7 / CentOS 7 (with RPM) .

Reloading code - Passenger + Python basics, Although this Library is a good source of information on using Passenger, you do So if you want to know what a command does and whether its behavior can  Phusion Passenger - the smart app server. 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. Passenger supports multiple programming languages, of which is one. Passenger can also serve multiple applications at the same time (it is multitenant).

Comments
  • Wow cool. I never know passenger also works with django.
  • I found this: gist.github.com/mpwoodward/3b446e573eb7b4d6f758c291c06f607e
  • where could I find request_handler.py ? I am using Passenger docker image.
  • This is the best (least hack-y) way.
  • This is it. This is nice and clear solution for Phusion Passenger / NginX / Flask combination. Given you have a Flask app called app.py and app.conf is your configuration file, you need to add e.g. passenger_python /usr/local/bin/python3 line to the server section (context) there (or whatever your path to Python3 executable is).