Troubleshooting Dreamhost + Passenger + Django

489 views
Skip to first unread message

Rob Newman

unread,
May 19, 2014, 11:59:01 PM5/19/14
to phusion-...@googlegroups.com
Hi there,

I posted a message on Stack Overflow about this already (http://stackoverflow.com/questions/23725107), and I am turning to this mailing list for additional help. It seems that Passenger is ignoring the version of Python I have installed in a virtualenv. I followed the instructions of Dreamhost to the letter (http://wiki.dreamhost.com/Passenger#Passenger_WSGI_and_virtualenv) but I am still getting the following error in my application:

An error occurred while starting the web application. It exited before signalling successful startup back to Phusion Passenger. Please read this article for more information about this problem.

Raw process output:

  File "/dh/nginx/passenger/helper-scripts/wsgi-loader.py", line 171
    buf = b''
            ^
SyntaxError: invalid syntax

Here is the content of my passenger_wsgi.py file:

import sys, os
INTERP = "/home/<user>/venv/tcs/bin/python2.6"
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
# print(sys.version)
sys.path.append(os.getcwd())
sys.path.append(os.path.join(os.getcwd(), '/home/<user>/<application>/<dir>'))
os.environ['DJANGO_SETTINGS_MODULE'] = "project.settings"
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

(<user>, <application> and <dir> hidden for obvious reasons)

When I uncomment the print(sys.version) I get the following output:

2.6.8 (unknown, Jul 10 2012, 08:03:16)
[GCC 4.3.2]

So I know that this version of Python is apparently supported:
http://www.modrails.com/documentation/Users%20guide%20Nginx.html#_supported_operating_systems_and_languages

Any ideas? I have already sent multiple support requests to Dreamhost, which are currently unanswered.

Thanks in advance,
- Rob Newman

Hongli Lai

unread,
May 20, 2014, 4:38:45 AM5/20/14
to phusion-passenger
The Dreamhost instructions are outdated. In those instructions, the
app checks whether it is running under the correct Python interpreter,
and if not, re-executes itself under the correct Python interpreter.
However, before Phusion Passenger ever loads your app, it first runs a
"loader" application which sets up the environment for your app. And
it is that loader application that requires Python >= 2.6. So the
re-execution trick only works properly if the Python that was used to
run the loader, is >= 2.6. At Dreamhost, that's apparently not the
case.

The correct way to run your app under a different Python is not by
re-executing itself, but by using the PassengerPython configuration
option inside the web server:
http://www.modrails.com/documentation/Users%20guide%20Apache.html#_passengerpython_lt_filename_gt
If Dreamhost gives you access to the Apache config file, you can set
it there directly. If they don't, then you *might* still be able to
customize it through .htaccess, assuming that Dreamhost gave you
access to do this through 'AllowOverride on'.

Otherwise, you might want to consider switching provider.
> --
> You received this message because you are subscribed to the Google Groups
> "Phusion Passenger Discussions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to phusion-passen...@googlegroups.com.
> To post to this group, send email to phusion-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/phusion-passenger.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/phusion-passenger/6af45196-ded6-46c3-8f12-069ed2dee83b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Phusion | Web Application deployment, scaling, and monitoring solutions

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

Hongli Lai

unread,
May 20, 2014, 4:42:19 AM5/20/14
to phusion-passenger
I see the web server is Nginx, not Apache. However the conclusion
remains the same: use the passenger_python option:
http://www.modrails.com/documentation/Users%20guide%20Nginx.html#_passenger_python_lt_filename_gt

Rob Newman

unread,
May 20, 2014, 4:41:48 PM5/20/14
to phusion-...@googlegroups.com, hon...@phusion.nl
Thanks Hongli Lai! I will test that out tonight!! Much appreciated.

Rob Newman

unread,
May 21, 2014, 12:32:46 AM5/21/14
to phusion-...@googlegroups.com, hon...@phusion.nl
Hi Hongli Lai,

This fixed it - thank you!!!!


On Tuesday, May 20, 2014 1:42:19 AM UTC-7, Hongli Lai wrote:
Reply all
Reply to author
Forward
0 new messages