deploying web2py on cpanel shared hosting

713 views
Skip to first unread message

whiskeyjuvenile

unread,
Oct 6, 2009, 3:41:42 PM10/6/09
to web2py-users
I'm trying to get web2py to work with cpanel shared hosting. I have
shell access.

Is there some walkthrough guide on how to get it working without using
apache as a proxy/not using the web2py-cherrypy server?

whiskeyjuvenile

unread,
Oct 6, 2009, 4:01:16 PM10/6/09
to web2py-users
http://groups.google.com/group/web2py/browse_thread/thread/10f93e6c50c11929/c2b3f1d93a5ae37e?lnk=gst&q=cpanel#c2b3f1d93a5ae37e

I'm trying to follow these directions.

I unzipped web2py_src.zip into /home/[username]/codebase/web2py/

I have .htaccess in /home/[username]/public_html/ that says:

Options +ExecCGI
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteBase /home/[username]/codebase/web2py/
RewriteRule ^dispatch\.fcgi/ - [L]
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]

I'm not sure what should be in dispatch.fcgi; should it be as folows:

#!/usr/bin/env python2.5

import os
import sys

WEB2PY_PATH = os.path.normpath('/path to web2py/')
os.chdir(WEB2PY_PATH)

if not WEB2PY_PATH in sys.path:
sys.path.append(WEB2PY_PATH)

from gluon.main import wsgibase
import gluon.contrib.gateways.fcgi
from gluon.contrib.gateways.fcgi import WSGIServer

if __name__ == '__main__':
WSGIServer(wsgibase).run()

mdipierro

unread,
Oct 6, 2009, 4:12:57 PM10/6/09
to web2py-users
http://web2py.com/examples/static/web2py_manual_cut.pdf

includes a chapter with deployment recipes and shows how to use
mod_wsgi.

Massimo

whiskeyjuvenile

unread,
Oct 6, 2009, 4:19:21 PM10/6/09
to web2py-users
Particularly, the instructions in 11.8 are somewhat unclear. Does the
web2py folder go in htdocs, or do the contents of the web2py folder go
in htdocs? Where should .htaccess reside?

whiskeyjuvenile

unread,
Oct 6, 2009, 4:18:08 PM10/6/09
to web2py-users
I tried to follow the instructions in section 11.8 on page 81/295, but
I'm getting 500 errors.

On Oct 6, 4:12 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:

whiskeyjuvenile

unread,
Oct 6, 2009, 7:14:33 PM10/6/09
to web2py-users
[ ]@[ ] [~/www]# python web2py_modpython.py
Traceback (most recent call last):
File "web2py_modpython.py", line 1, in ?
from mod_python import apache
File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line
30, in ?
import _apache
ImportError: No module named _apache

Is my host setup incorrectly?

whiskeyjuvenile

unread,
Oct 6, 2009, 7:35:43 PM10/6/09
to web2py-users
Here's the specific apache log error:

[Tue Oct 06 18:30:54 2009] [error] [client MY IP] AttributeError:
module '/home/[username]/public_html/web2py_modpython.py' contains no
'handler'
[Tue Oct 06 18:30:54 2009] [error] [client MY IP] Filename: '/home/
[username]/public_html/500.shtml'
[Tue Oct 06 18:30:54 2009] [error] [client MY IP] Directory: '/home/
[username]/public_html/'
[Tue Oct 06 18:30:54 2009] [error] [client MY IP] DocumentRoot: '/home/
[username]/public_html'
[Tue Oct 06 18:30:54 2009] [error] [client MY IP] File "/home/
[username]/public_html/gluon/utils.py", line 10, in ?\n import
hashlib
[Tue Oct 06 18:30:54 2009] [error] [client MY IP] File "/home/
[username]/public_html/gluon/validators.py", line 25, in ?\n from
utils import hash, get_digest
[Tue Oct 06 18:30:54 2009] [error] [client MY IP] File "/home/
[username]/public_html/gluon/html.py", line 25, in ?\n from
validators import *
[Tue Oct 06 18:30:54 2009] [error] [client MY IP] File "/home/
[username]/public_html/gluon/restricted.py", line 24, in ?\n from
html import BEAUTIFY
[Tue Oct 06 18:30:54 2009] [error] [client MY IP] File "/home/
[username]/public_html/gluon/main.py", line 38, in ?\n from
restricted import RestrictedError
[Tue Oct 06 18:30:54 2009] [error] [client MY IP] File "/home/
[username]/public_html/modpythonhandler.py", line 36, in ?\n import
gluon.main
[Tue Oct 06 18:30:54 2009] [error] [client MY IP] File "/home/
[username]/public_html/web2py_modpython.py", line 2, in ?\n import
modpythonhandler
[Tue Oct 06 18:30:54 2009] [error] [client MY IP] Filename: '/home/
[username]/public_html/'
[Tue Oct 06 18:30:54 2009] [error] [client MY IP] Directory: '/home/
[username]/public_html/'
[Tue Oct 06 18:30:54 2009] [error] [client MY IP] DocumentRoot: '/home/
[username]/public_html'

Graham Dumpleton

unread,
Oct 6, 2009, 7:38:15 PM10/6/09
to web2py-users
You don't have mod_python installed for that Apache instance. The
'_apache' module is a special embedded module created by mod_python
Apache module within memory space of Apache process at run time.

Graham

whiskeyjuvenile

unread,
Oct 6, 2009, 7:42:21 PM10/6/09
to web2py-users
Thanks Graham. I caught that after some googling, and it seems from
the apache log that it isn't a problem. I can't figure out what
they're complaining about the handler now though...

On Oct 6, 7:38 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:

Graham Dumpleton

unread,
Oct 6, 2009, 7:48:02 PM10/6/09
to web2py-users


On Oct 7, 10:35 am, whiskeyjuvenile <whiskeyjuven...@gmail.com> wrote:
> Here's the specific apache log error:
>
> [Tue Oct 06 18:30:54 2009] [error] [client MY IP] AttributeError:
> module '/home/[username]/public_html/web2py_modpython.py' contains no
> 'handler'

Presumably you created:

web2py_modpython.py

That file isn't part of web2py.

The error means that whatever you stuck in that file is wrong. Post
the contents of that file.

Graham

whiskeyjuvenile

unread,
Oct 6, 2009, 7:57:51 PM10/6/09
to web2py-users
from mod_python import apache
import modpythonhandler

def handler(req):
req.subprocess_env['PATH_INFO'] = req.subprocess_env['SCRIPT_URL']
return modpythonhandler.handler(req)

I'm following the instructions from
http://groups.google.com/group/web2py/browse_thread/thread/bc354fb111d4bc31/415e5108ab3c38a7?lnk=raot

On Oct 6, 7:48 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:

whiskeyjuvenile

unread,
Oct 6, 2009, 8:45:38 PM10/6/09
to web2py-users
If, following those instructions, I change, in .htaccess
PythonHandler web2py_modpython

to

PythonHandler modpythonhandler

The error is AttributeError: module '/home/[username]/public_html/
modpythonhandler.py' contains no 'handler'


On Oct 6, 7:57 pm, whiskeyjuvenile <whiskeyjuven...@gmail.com> wrote:
> from mod_python import apache
> import modpythonhandler
>
> def handler(req):
>         req.subprocess_env['PATH_INFO'] = req.subprocess_env['SCRIPT_URL']
>         return modpythonhandler.handler(req)
>
> I'm following the instructions fromhttp://groups.google.com/group/web2py/browse_thread/thread/bc354fb111...

whiskeyjuvenile

unread,
Oct 6, 2009, 8:57:31 PM10/6/09
to web2py-users
This works:

from mod_python import apache

def handler(req):
req.content_type = 'text/plain'
req.write("Hello World!")
return apache.OK

If I insert the line "import modpythonhandler" it fails.

It seems like "import hashlib" in gluon/utils.py is failing

dekushrub

unread,
Oct 15, 2009, 11:47:27 AM10/15/09
to web2py-users
Did you ever figure it out? I'm trying to do the same thing

On Oct 6, 7:57 pm, whiskeyjuvenile <whiskeyjuven...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages