python - Cherrypy behing apache with mod_python -
i have problem cherrypy deployment behind apache mod_python.
i have apache configuration:
4 <virtualhost *> 5 serveradmin martin@podhola.com 6 servername pyth.madphoto.eu 7 documentroot /development/webadmin-interface/ 8 # indexes + directory root. 9 <location /> 10 pythonpath "sys.path+['/development/webadmin-interface']" 11 sethandler python-program 12 pythonhandler cherrypy._cpmodpy::handler 13 pythonoption cherrypy.setup main::start 14 pythondebug on 15 </location> 16 17 # logfiles 18 errorlog /www/madphoto.eu/pyth/logs/error.log 19 customlog /www/madphoto.eu/pyth/logs/ccess.log combined 20 </virtualhost>
and cherrypy code start entire website
#!/usr/bin/env python 2 # -*- coding: utf8 -*- 3 4 import os.path 5 import cherrypy 6 mako.template import template 7 mako.lookup import templatelookup 8 mako import exceptions 9 mako.exceptions import richtraceback 10 readfromdb import * 11 deletefromdb import * 12 inserttodb import * 13 basepage import basepage 14 modifyentrydb import * 15 #from cherrypy.process.plugins import daemonizer 16 #from cherrypy import application 17 18 current_dir = os.path.dirname(os.path.abspath(__file__)) 19 mainlookup = templatelookup(directories=['./templates'], output_encoding='utf-8', input_encoding='utf-8', en coding_errors='replace', format_exceptions = true) 20 21 class main(basepage): 22 readfromdb = readfromdb() 23 deletefromdb = deletefromdb() 24 inserttodb = inserttodb() 25 modifyentrydb = modifyentrydb() 26 27 def index(self): 28 try: 29 mindextemplate = mainlookup.get_template("main_index.txt") 30 return mindextemplate.render() 31 except: 32 33 traceback = richtraceback() 34 (filename, lineno, function, line) in traceback.traceback: 35 print "file %s, line %s, in %s" % (filename, lineno, function) 36 print line, "\n" 37 print "%s: %s" % (str(traceback.error.__class__.__name__), traceback.error) 38 39 index.exposed = true 40 41 #config = { 42 # '/bootstrap/css':{ 43 # 'tools.staticdir.on': true, 44 # 'tools.staticdir.dir': os.path.abspath(os.path.join(os.path.dirname(__file__), 'static')) 45 # } 46 #} 47 def start(): 48 cherrypy.tree.mount(main(),config="/development/webadmin-interface/webadmin.conf") 49 cherrypy.engine.start() 50 51 52 53 #cherrypy.quickstart(main(), "/", "webadmin.conf")
and first refresh of site doing 403 forbidden, , second time in apache error log
[21/may/2013:11:48:38] mod_python traceback (most recent call last): file "/usr/lib/pymodules/python2.6/cherrypy/_cpmodpy.py", line 139, in handler setup(req) file "/usr/lib/pymodules/python2.6/cherrypy/_cpmodpy.py", line 84, in setup func() file "/development/webadmin-interface/main.py", line 49, in start cherrypy.engine.start() file "/usr/lib/pymodules/python2.6/cherrypy/process/wspbus.py", line 184, in start self.publish('start') file "/usr/lib/pymodules/python2.6/cherrypy/process/wspbus.py", line 147, in publish output.append(listener(*args, **kwargs)) file "/usr/lib/pymodules/python2.6/cherrypy/_cpserver.py", line 90, in start serveradapter.start(self) file "/usr/lib/pymodules/python2.6/cherrypy/process/servers.py", line 53, in start wait_for_free_port(*self.bind_addr) file "/usr/lib/pymodules/python2.6/cherrypy/process/servers.py", line 251, in wait_for_free_port raise ioerror("port %r not free on %r" % (port, host)) ioerror: port 8080 not free on '127.0.0.1'
but not working, followed many manuals (i try different settings still not working)
i have debian squeeze server, cherrypy 3.1.2-1, apache2.
in standalone startup built-in server of cherrypy works perfectly.
please can help? thanks!
you starting cherrypy server along apache, start function configure , mount application not start server, should this:
def start(): cherrypy.tree.mount(main(), config="/development/webadmin-interface/webadmin.conf")
the module _cpmodpy
have more information readable with:
python -m pydoc cherrypy._cpmodpy
as general recommendation should consider use mod_wsgi, mod_python unmaintained , considered deprecated in favor of mod_wsgi.
Comments
Post a Comment