Update 2019.12.06: I have moved from DreamHost to Google Cloud VPS. If this post does not work for you, please see alternative method in a comment by Chris.
After hours of research and testing, I would like to share my experience using
pyenv + passenger wsgi + web2py on Dreamhost shared hosting as of 08.2017
What I did differently than most guides online is that I only have to edit
.htaccess file (in domain root folder) with: (Credit: ASO)
PassengerEnabled on PassengerAppRoot /home/%USER%/ PassengerPython /home/%USER%/.pyenv/shims/python
Most importantly and strangely, I didn’t need to modify
passenger_wsgi.py (handlers/wsgihandler.py) at all. Most guides online (this; this; and many others) require adding two lines after
import os, such as this one:
INTERP = "/home/%USER%/.pyenv/shims/python" #INTERP is present twice so that the new Python interpreter knows the actual executable path if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
But I couldn’t make it work if I modify
passenger_wsgi.py. It seems
.htaccess is sufficient to specify pyenv environment.
Some guides also suggest make a pyenv “virtualenv” within app folder, I found it is not required.
Assuming you already know:
This is what I did:
- Enable passenger on Dreamhost panel. A folder
publicwill be created. Don’t worry.
- Put web2py files into your domain root folder, which is parent folder of
cp handlers/wsgihandler.py passenger_wsgi.py
.htaccessin domain root folder as described above.
tmp/folder under my web root folder, did a
touch restart.txtto get passenger to reload
Your web2py site should now load in your browser. If you use free “Let’s Encrypt” SSL from Dreamhost panel, you should be able to verify your pyenv python environment from admin interface by accessing https. I did verify mine.
I am not sure ssh tunnel method could serve as verification, because you are serving admin from a separate web2py instance running from your shell.
Hope this will help fellow web2py users. Thank all the web2py team for providing web2py.