Dreamhost deployment

302 views
Skip to first unread message

sasogeek

unread,
Feb 6, 2014, 8:37:08 PM2/6/14
to web...@googlegroups.com
how do I install python 2.7 and web2py on dreamhost with a windows environment? I looked at the dreamhost wiki but their tutorial assumes installation from a linux environment... help?

LightDot

unread,
Feb 7, 2014, 5:48:31 AM2/7/14
to web...@googlegroups.com
What kind of access do you have, is it a VPS or a shared hosting, etc.? Did you try their user support?

Regards

sasogeek

unread,
Feb 8, 2014, 3:42:38 PM2/8/14
to web...@googlegroups.com
Shared hosting

NeoToren

unread,
Feb 8, 2014, 4:55:50 PM2/8/14
to web...@googlegroups.com
If you want to deploy quickly and pain free - try PythonAnywhere.
I just deployed there recently and the whole process took literally minutes.
Web2Py (and MySQL) are already installed there and wait for you as consoles.
So you have the familiar W2P interface waiting for you to work in the cloud like you are doing it locally.
Good luck

sasogeek

unread,
Feb 9, 2014, 2:39:25 PM2/9/14
to web...@googlegroups.com
I would, except their pricing is too expensive for me right now.

NeoToren

unread,
Feb 9, 2014, 5:00:37 PM2/9/14
to web...@googlegroups.com
PythonAnywhere has a beginner's plan for ...free

eclair

unread,
Feb 10, 2014, 8:19:07 PM2/10/14
to web...@googlegroups.com
I have deployed web2py on dreamhost. It's not too hard to do, but the instructions that you find out there aren't that clear and kinda dated.
So, here is an updated step-by-step guide to deploying web2py on dreamhost that I have compiled from various sources and tested myself.

Before you get started though, you'll need to have a VPS. If you don't, you'll have to enable it. Once that is done setup your ssh access (http://wiki.dreamhost.com/SSH).

The default python on dreamhost is old and we can't install modules. 
So, we need to install our own python and virtualenv.  
Let's make a directory for python to live in(I'm assuming we are in the home directory here).
NOTE: I'm not sure how this all pans out if you have different users setup on with different domains running under their home directories. I'll just assume you have one user and run all of your domains under that, because that's what I do.

Connect via ssh.


[dreamvps]$
[dreamvps]$ mkdir python
[dreamvps]$ cd python



Feel free to choose some other directory if you really want to.

Now we need to get a newer python.


[dreamvps]$ wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.bz2
[dreamvps]$ tar xjf Python-2.7.6.tar.bz2



Time to build and install. 
Notice that we configure to our home dir.


[dreamvps]$ cd Python-2.7.6
[dreamvps]$ ./configure --prefix=$HOME/python
[dreamvps]$ make
[dreamvps]$ make install



Assuming there were no errors, check to make sure it works.


[dreamvps]$ ~/python/bin/python
Python 2.7.6 (default, Feb 10 2014, 07:19:04)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.



Let's append our new python directory to our PATH.


[dreamvps]$ echo 'export PATH=$HOME/python/bin:$PATH' >> ~/.bash_profile
[dreamvps]$ source ~/
.bash_profile



With our profile reloaded we should be able run our new build of python directly.


[dreamvps]$ python
Python 2.7.6 (default, Feb 10 2014, 07:19:04)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.



Time to get virtualenv installed.


[dreamvps]$ ~/python
[dreamvps]$ wget http:/
/pypi.python.org/packages/source/v/virtualenv/virtualenv-1.9.1.tar.gz --no-check-certificate
[dreamvps]$ tar xzf virtualenv-1.9.1.tar.gz
[dreamvps]$ cd virtualenv-1.9.1
[dreamvps]$ python setup.
py install



Assuming you had no issues, test to make sure everything is peachy.


[dreamvps]$ virtualenv --version
1.9.1



Let's make a virtualenv to test it out.


[dreamvps]$ cd ~
[dreamvps]$ mkdir env
[dreamvps]$ virtualenv env/test-env
New python executable in env/test-env/bin/python
Installing setuptools............done.
Installing pip...............done.



Now activate it.


[dreamvps]$ source ~/env/test-env/bin/activate
(test-env)[dreamvps]$



If everything seems to be working, we can make a virtualenv for web2py.



(test-env)[dreamvps]$ deactivate
[dreamvps]$ virtualenv env/web2py-env
New python executable in env/web2py-env/bin/python
Installing setuptools............done.
Installing pip...............done.
[dreamvps]$ source ~/env/web2py-env/bin/activate
(web2py-env)[dreamvps]$





I'm going to assume you have your domain/sub-domain(s) setup to use Passenger at this point. (no? go here: http://wiki.dreamhost.com/Passenger#Configuration_Steps)
(Make sure the root of your web directory is yourdomain.com/public. This is also in the domain settings where you enable Passenger)
Get whatever modules you need and deactivate the virtualenv.


(web2py-env)[dreamvps]$ easy_install MySQL-python
...
Processing dependencies for MySQL-python
Finished processing dependencies for MySQL-python
(web2py-env)[dreamvps]$ deactivate
[dreamvps]$



Let's get web2py installed. 
Download the latest source release and unzip it into your home directory.


[dreamvps]$ cd ~/yourdomain.com
[dreamvps]$ wget http:/
/www.web2py.com/examples/static/web2py_src.zip
[dreamvps]$ unzip web2py_src.zip
[dreamvps]$ rm web2py_src.zip




We need to move wsgihandler.py out of the handler director so web2py can use it.


[dreamvps]$ mv web2py/handlers/wsgihandler.py web2py/.



Now we need to edit wsgihandler.py so it will work.



[dreamvps]$ nano web2py/wsgihandler.py

(you don't have to use nano it's just my preference)


We need to add two lines just after import os to get web2py to use the virtualenv we setup for it (change username and yourdomain.com to your needs obviously):

...
INTERP
= '/home/username/env/web2py-env/bin/python2.7'
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
...



Next, look for this line:

...
path
= os.path.dirname(os.path.abspath(__file__))
...


And change it to point directly to the web2py directory:

...
path
= '/home/username/yourdomain.com/web2py/'
...


So it should look like this:

...
import sys
import os
INTERP
= '/home/username/env/web2py-env/bin/python2.7'
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
path
= '/home/username/yourdomain.com/web2py/'
os
.chdir(path)
...



One more step, we need to symlink to the wsgihelper so Passenger can use it. Assuming you are still in the ~/yourdomain.com directory:


[dreamvps]$ ln -s /home/username/yourdomain.com/web2py/wsgihandler.py passenger_wsgi.py


At this point, you should have a working copy of web2py running. If not, try rebooting your VPS.



Sources:


P.S. Before people ask me why I don't just use pythonanywhere, I do use it for most of my own projects.



On Thursday, February 6, 2014 8:37:08 PM UTC-5, sasogeek wrote:

SJ

unread,
Dec 8, 2014, 1:03:32 PM12/8/14
to web...@googlegroups.com
Experts, I am a newbie, getting following error, while deploying on dreamhost.
Before this it was showing the public directory files view.

Raw process output:

!> Ready
!> socket: main;unix:/tmp/passenger.1.0.20902/generation-22/backends/wsgi.899;session;1
!> 

Any pointers please, i have followed the installation process answered by eclair.

Thanks

4ringmaster

unread,
Oct 23, 2016, 6:40:24 PM10/23/16
to web2py-users
It's been a while since this thread had seen any traffic but I was trying to deploy on dreamhost and ran into the same problem. I found this which solved it:


In passenger_wsgi.py, web2py overwrites stdout with stderr but Passenger needs stdout to talk to the application. Commenting that line out fixed my problem. 
Reply all
Reply to author
Forward
0 new messages