web2py on dreamhost shell account?

187 views
Skip to first unread message

richard.ree

unread,
Jan 7, 2009, 12:09:41 AM1/7/09
to web2py Web Framework
Anyone running web2py on dreamhost?

I folllowed the instructions at http://wiki.dreamhost.com/Web2py but
couldn't figure out how to adapt them to my case. I have a shell
account but not a WebID so I have no access to the control panel. In
my home directory, web content is served from ~/www, which is visible
as www.mydomain.net/myusername. I'd like to set up web2py such that
it's accessible as, e.g., www.mydomain.net/myusername/web2py, or
better yet, have a specific web2py application visible as
www.mydomain.net/myusername/myapp. On another server where I control
apache I used ProxyPass directives to do this.

Is it a matter of using the wsgi handler?

I can start web2py on the dreamhost server and tunnel port 8000 to my
local machine - this works - but www.mydomain.net:8000 does not.

Thanks in advance for any suggestions,
-Rick

Timothy Farrell

unread,
Jan 7, 2009, 8:57:47 AM1/7/09
to web...@googlegroups.com
I have mine working like this:

1) Extract web2py to ~/web2py
2) Place the attached dispatch.fcgi in your webroot (~/www you said)
3) Modify dispatch.fcgi to point to the right directories in your situation
4) Place the attached htaccess file in your webroot.  (Make sure you rename it to .htaccess )

No need to run web2py, FastCGI takes care of it.  I've had some trouble with routes with this setup, but I'm not sure if it's me or the setup.  =)

Let me know if that doesn't work for you.  One thing to note is that you must specify python2.5 (1st line in dispatch.fcgi) because dreamhost's default `python` points to python 2.4.4

-tim
-- 
Timothy Farrell <tfar...@swgen.com>
Computer Guy
Statewide General Insurance Agency (www.swgen.com)
htaccess
dispatch.fcgi

richard.ree

unread,
Jan 7, 2009, 2:32:41 PM1/7/09
to web2py Web Framework
I followed your steps but got the following errors.

1. The .htaccess file causes this snippet of html to be returned for
all requests: <html><body>Error</body></html>
2. When I run dispatch.fcgi unmodified, it bails with "ImportError: No
module named fcgi" even though the import from gluon.contrib.gateways
is successful (I can print it, dir() it, and so on)
3. I modify dispatch.fcgi to import WSGIServer as "from
gluon.contrib.gateways.fcgi import WSGIServer" - this runs, but then I
get the following:
>>>
WARNING:root:unable to import dbhash
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 303 SEE OTHER
Content-Type: text/html
Location: /welcome/default/index
Content-Length: 66

You are being redirected <a href="/welcome/default/index">here</a>
<<<

I realize I can ignore the WSGIServer errors, but what about the 303
status? Strange. I tried google and the dreamhost wiki and forums
for answers but no luck. Thanks for your help.

-Rick

On Jan 7, 7:57 am, Timothy Farrell <tfarr...@swgen.com> wrote:
> I have mine working like this:
> 1) Extract web2py to ~/web2py
> 2) Place the attached dispatch.fcgi in your webroot (~/www you said)
> 3) Modify dispatch.fcgi to point to the right directories in your situation
> 4) Place the attached htaccess file in your webroot.  (Make sure you rename it to .htaccess )
> No need to run web2py, FastCGI takes care of it.  I've had some trouble with routes with this setup, but I'm not sure if it's me or the setup.  =)
> Let me know if that doesn't work for you.  One thing to note is that you must specify python2.5 (1st line in dispatch.fcgi) because dreamhost's default `python` points to python 2.4.4
> -tim
> richard.ree wrote:Anyone running web2py on dreamhost? I folllowed the instructions athttp://wiki.dreamhost.com/Web2pybut couldn't figure out how to adapt them to my case. I have a shell account but not a WebID so I have no access to the control panel. In my home directory, web content is served from ~/www, which is visible aswww.mydomain.net/myusername. I'd like to set up web2py such that it's accessible as, e.g.,www.mydomain.net/myusername/web2py, or better yet, have a specific web2py application visible aswww.mydomain.net/myusername/myapp. On another server where I control apache I used ProxyPass directives to do this. Is it a matter of using the wsgi handler? I can start web2py on the dreamhost server and tunnel port 8000 to my local machine - this works - butwww.mydomain.net:8000does not. Thanks in advance for any suggestions, -Rick-- Timothy Farrell<tfar...@swgen.com>Computer Guy Statewide General Insurance Agency (www.swgen.com)
>
> [htaccess< 1K ]RewriteEngine On
> RewriteBase /
> RewriteRule ^dispatch\.fcgi/ - [L]
> RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
>
> [dispatch.fcgi< 1K ]#!/usr/bin/env python2.5
>
> import os
> import sys
>
> os.chdir('/home/<username>/web2py')
>
> path=os.path.normpath('/home/<username>/web2py/')
> if not path in sys.path: sys.path.append(path)
>
> import gluon.main
> import gluon.contrib.gateways.fcgi as fcgi
> application=gluon.main.wsgibase
>
> if __name__ == '__main__':
>     from fcgi import WSGIServer
>     WSGIServer(application).run()

Timothy Farrell

unread,
Jan 7, 2009, 2:50:28 PM1/7/09
to web...@googlegroups.com
Oops, I overlooked that last import in my attachment.  You were right to fix it how you did.

Your step 3 tells me that it's working.  This is roughly what I get when I run mine.  Now it's just a matter of getting Apache to recognize your dispatch.fcgi.  Things to check:
- permissions:
  $ chmod 664 .htaccess
  $ chmod 755 dispatch.fcgi
  $ chown <your username> ~/www/*
  $ chgrp <your usergroup> ~/www/*

Try that and give Dreamhost's fcgi daemon 10 minutes to notice the changes.  Let me know if we need to fiddle some more.

-tim

richard.ree

unread,
Jan 7, 2009, 4:15:42 PM1/7/09
to web2py Web Framework
The permissions checked out, but I still get the same error html
snippet. The problem seems to be with the last line in .htacces:

RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]

If I comment it out, I get the directory index where dispatch.fcgi
and .htaccess are.

Other content from ~/www is served ok, unless I put .htaccess in ~/www
- then it all gets blocked with the same error message.
I tried putting dispatch.fcgi and .htaccess in a subdirectory, ~/www/
w2p - this solves the problem for ~/www but not for ~/www/w2p.

Sorry this thread is not really web2py related, but it might help
others use it on dreamhost...
> richard.ree wrote:I followed your steps but got the following errors. 1. The .htaccess file causes this snippet of html to be returned for all requests: <html><body>Error</body></html> 2. When I run dispatch.fcgi unmodified, it bails with "ImportError: No module named fcgi" even though the import from gluon.contrib.gateways is successful (I can print it, dir() it, and so on) 3. I modify dispatch.fcgi to import WSGIServer as "from gluon.contrib.gateways.fcgi import WSGIServer" - this runs, but then I get the following:WARNING:root:unable to import dbhash WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI! WSGIServer: missing FastCGI param SERVER_NAME required by WSGI! WSGIServer: missing FastCGI param SERVER_PORT required by WSGI! WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI! Status: 303 SEE OTHER Content-Type: text/html Location: /welcome/default/index Content-Length: 66 You are being redirected <a href="/welcome/default/index">here</a> <<< I realize I can ignore the WSGIServer errors, but what about the 303 status? Strange. I tried google and the dreamhost wiki and forums for answers but no luck. Thanks for your help. -Rick On Jan 7, 7:57 am, Timothy Farrell<tfarr...@swgen.com>wrote:I have mine working like this: 1) Extract web2py to ~/web2py 2) Place the attached dispatch.fcgi in your webroot (~/www you said) 3) Modify dispatch.fcgi to point to the right directories in your situation 4) Place the attached htaccess file in your webroot.  (Make sure you rename it to .htaccess ) No need to run web2py, FastCGI takes care of it.  I've had some trouble with routes with this setup, but I'm not sure if it's me or the setup.  =) Let me know if that doesn't work for you.  One thing to note is that you must specify python2.5 (1st line in dispatch.fcgi) because dreamhost's default `python` points to python 2.4.4 -tim richard.ree wrote:Anyone running web2py on dreamhost? I folllowed the instructions athttp://wiki.dreamhost.com/Web2pybut couldn't figure out how to adapt them to my case. I have a shell account but not a WebID so I have no access to the control panel. In my home directory, web content is served from ~/www, which is visible aswww.mydomain.net/myusername. I'd like to set up web2py such that it's accessible as, e.g.,www.mydomain.net/myusername/web2py, or better yet, have a specific web2py application visible aswww.mydomain.net/myusername/myapp. On another server where I control apache I used ProxyPass directives to do this. Is it a matter of using the wsgi handler? I can start web2py on the dreamhost server and tunnel port 8000 to my local machine - this works - butwww.mydomain.net:8000does not. Thanks in advance for any suggestions, -Rick-- Timothy Farrell<tfar...@swgen.com>Computer Guy Statewide General Insurance Agency (www.swgen.com) [htaccess< 1K ]RewriteEngine On RewriteBase / RewriteRule ^dispatch\.fcgi/ - [L] RewriteRule ^(.*)$ dispatch.fcgi/$1 [L] [dispatch.fcgi< 1K ]#!/usr/bin/env python2.5 import os import sys os.chdir('/home/<username>/web2py') path=os.path.normpath('/home/<username>/web2py/') if not path in sys.path: sys.path.append(path) import gluon.main import gluon.contrib.gateways.fcgi as fcgi application=gluon.main.wsgibase if __name__ == '__main__':     from fcgi import WSGIServer     WSGIServer(application).run()-- Timothy Farrell<tfar...@swgen.com>Computer Guy Statewide General Insurance Agency (www.swgen.com)

richard.ree

unread,
Jan 14, 2009, 6:45:33 PM1/14/09
to web2py Web Framework
For those interested I made some progress on my dreamhost issues. The
following .htaccess launches web2py (/path/to/site/ is where
dispatch.fcgi and .htaccess reside):

Options +ExecCGI
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteBase /path/to/site/
RewriteRule ^dispatch\.fcgi/ - [L]
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]

I want to see www.mydomain.net/myser/path/to/site/welcome/default/index,
but instead it redirects to www.mydomain.net/welcome/default/index. I
tried to figure out how to use routes to solve this - can anyone help?

thanks!
-Rick

On Jan 7, 3:15 pm, "richard.ree" <richard.h....@gmail.com> wrote:
> The permissions checked out, but I still get the same error html
> snippet.  The problem seems to be with the last line in .htacces:
>
> RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
>
> If I comment it out, I get the directory index where dispatch.fcgi
> and .htaccess are.
>
> Other content from ~/www is served ok, unless I put .htaccess in ~/www
> - then it all gets blocked with the same error message.
> I tried putting dispatch.fcgi and .htaccess in a subdirectory, ~/www/
> w2p - this solves the problem for ~/www but not for ~/www/w2p.
>
> Sorry this thread is not really web2py related, but it might help
> others use it ondreamhost...
>
> On Jan 7, 1:50 pm, Timothy Farrell <tfarr...@swgen.com> wrote:
>
> > Oops, I overlooked that last import in my attachment.  You were right to fix it how you did.
> > Your step 3 tells me that it's working.  This is roughly what I get when I run mine.  Now it's just a matter of getting Apache to recognize your dispatch.fcgi.  Things to check:
> > - permissions:
> >   $ chmod 664 .htaccess
> >   $ chmod 755 dispatch.fcgi
> >   $ chown <your username> ~/www/*
> >   $ chgrp <your usergroup> ~/www/*
> > Try that and giveDreamhost'sfcgi daemon 10 minutes to notice the changes.  Let me know if we need to fiddle some more.
> > -tim
> > richard.ree wrote:I followed your steps but got the following errors. 1. The .htaccess file causes this snippet of html to be returned for all requests: <html><body>Error</body></html> 2. When I run dispatch.fcgi unmodified, it bails with "ImportError: No module named fcgi" even though the import from gluon.contrib.gateways is successful (I can print it, dir() it, and so on) 3. I modify dispatch.fcgi to import WSGIServer as "from gluon.contrib.gateways.fcgi import WSGIServer" - this runs, but then I get the following:WARNING:root:unable to import dbhash WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI! WSGIServer: missing FastCGI param SERVER_NAME required by WSGI! WSGIServer: missing FastCGI param SERVER_PORT required by WSGI! WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI! Status: 303 SEE OTHER Content-Type: text/html Location: /welcome/default/index Content-Length: 66 You are being redirected <a href="/welcome/default/index">here</a> <<< I realize I can ignore the WSGIServer errors, but what about the 303 status? Strange. I tried google and thedreamhostwiki and forums for answers but no luck. Thanks for your help. -Rick On Jan 7, 7:57 am, Timothy Farrell<tfarr...@swgen.com>wrote:I have mine working like this: 1) Extract web2py to ~/web2py 2) Place the attached dispatch.fcgi in your webroot (~/www you said) 3) Modify dispatch.fcgi to point to the right directories in your situation 4) Place the attached htaccess file in your webroot.  (Make sure you rename it to .htaccess ) No need to run web2py, FastCGI takes care of it.  I've had some trouble with routes with this setup, but I'm not sure if it's me or the setup.  =) Let me know if that doesn't work for you.  One thing to note is that you must specify python2.5 (1st line in dispatch.fcgi) becausedreamhost'sdefault `python` points to python 2.4.4 -tim richard.ree wrote:Anyone running web2py ondreamhost? I folllowed the instructions athttp://wiki.dreamhost.com/Web2pybut couldn't figure out how to adapt them to my case. I have a shell account but not a WebID so I have no access to the control panel. In my home directory, web content is served from ~/www, which is visible aswww.mydomain.net/myusername. I'd like to set up web2py such that it's accessible as, e.g.,www.mydomain.net/myusername/web2py, or better yet, have a specific web2py application visible aswww.mydomain.net/myusername/myapp. On another server where I control apache I used ProxyPass directives to do this. Is it a matter of using the wsgi handler? I can start web2py on thedreamhostserver and tunnel port 8000 to my local machine - this works - butwww.mydomain.net:8000does not. Thanks in advance for any suggestions, -Rick-- Timothy Farrell<tfarr...@swgen.com>Computer Guy Statewide General Insurance Agency (www.swgen.com) [htaccess< 1K ]RewriteEngine On RewriteBase / RewriteRule ^dispatch\.fcgi/ - [L] RewriteRule ^(.*)$ dispatch.fcgi/$1 [L] [dispatch.fcgi< 1K ]#!/usr/bin/env python2.5 import os import sys os.chdir('/home/<username>/web2py') path=os.path.normpath('/home/<username>/web2py/') if not path in sys.path: sys.path.append(path) import gluon.main import gluon.contrib.gateways.fcgi as fcgi application=gluon.main.wsgibase if __name__ == '__main__':     from fcgi import WSGIServer     WSGIServer(application).run()-- Timothy Farrell<tfarr...@swgen.com>Computer Guy Statewide General Insurance Agency (www.swgen.com)

Timothy Farrell

unread,
Jan 15, 2009, 8:45:25 AM1/15/09
to web...@googlegroups.com
My guess would be to use a rule that looks something like:

('/path/to/site/(?P<path>[\w\./_-]+)','/\g<path>')

Basically we want web2py to think that it is working at '/' when in fact
it is working at '/path/to/site/'

Try that.

-tim
--
Timothy Farrell <tfar...@swgen.com>

TakeTheStage

unread,
Jan 21, 2009, 10:22:28 PM1/21/09
to web2py Web Framework
I followed the above along with http://wiki.dreamhost.com/Web2py.
Finally got everything working; however, cant access the admin pages.
I get this message when I attempt:
"Admin is disabled because unsecure channel".

I tried the workaround mentioned in the wiki, but its a bit outdated
and no longer applies. Any ideas?



P.S. I'm using trunk.

mdipierro

unread,
Jan 22, 2009, 2:45:47 AM1/22/09
to web2py Web Framework
http://groups.google.com/group/web2py/browse_thread/thread/93a9e612f8455d78

On Jan 21, 9:22 pm, TakeTheStage <forthepo...@gmail.com> wrote:
> I followed the above along withhttp://wiki.dreamhost.com/Web2py.

Mike Axelrod

unread,
Mar 5, 2009, 6:50:01 PM3/5/09
to web2py Web Framework
I have successfully set up web2py on my dreamhost account thanks to
this thread and the instructions on http://wiki.dreamhost.com/Web2py

Thank you all.

I do have a comment/question:

To get it to work I ended up putting the entire contents of the web2py
package in my webroot. This seems a bit messy as I assume there is
stuff in there that doesn't really need to be there (although I don't
know completely what's needed and what's not). It also clutters up
my webroot and I'm not even sure how secure this technique is?

Also what I did seems contrary to an earlier comment that suggested
the web2py package of stuff should be in ~/web2py. I had tried that
first but got errors. (My dispatch.cgi could not see the gluon
library.)

The wiki page is a somewhat silent on a recommended directory
structure for all this stuff.

Regardless it does work and I'm excited to try this stuff out.
However I would appreciate and suggestions to refine the situation.
Also it might be nice if we could get a little more specific on the
wiki page for future generations. I burned a lot of time going back
and forth between this thread and the wiki page... I didn't mind, but
I imagine some folks might give before getting it going.

I look forward to reading any other comments,

Mike

P.S. by the way very nice framework! Kudos.

Reply all
Reply to author
Forward
0 new messages