我没有为此做Apache设置它是由托管公司完成的,显然他们对Python和mod_python知之甚少,所以我卡住了我只能访问.htaccess文件和我的自己的代码。
的.htaccess
AddHandler python-program .py
PythonHandler wsgiref.modpython_gateway::handler
PythonOption wsgi.application code::main
code.py
#!/usr/bin/python
import web
urls = (
'/(.*)', 'hello'
)
main = web.wsgifunc(web.webpyfunc(urls, globals()))
class hello:
def GET(self, name):
if not name:
name = 'Pussy'
return 'Hello, '+ name +'!'
#if __name__ == "__main__":
#main = web.wsgifunc(web.webpyfunc(urls, globals()))
我在加载code.py文件时看到的错误消息
MOD_PYTHON ERROR
ProcessId: 30954
Interpreter: 'example.dk'
ServerName: 'example.dk'
DocumentRoot: '/var/www/example.dk/web'
URI: '/code.py'
Location: None
Directory: '/var/www/example.dk/web/'
Filename: '/var/www/example.dk/web/code.py'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'wsgiref.modpython_gateway::handler'
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1229, in _process_target
result = _execute_target(config, req, object, arg)
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1128, in _execute_target
result = object(arg)
File "/usr/lib/python2.7/wsgiref/modpython_gateway.py", line 206, in handler
app = getattr(module, objname)
AttributeError: 'module' object has no attribute 'main'
我错过了什么?我使用http://webpy.org/deployment作为参考。服务器环境
Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64