0
web.py'Hello,world'示例在Ubuntu 14.04的Apache上给出了404错误:“在此服务器上找不到请求的URL/api /。”Ubuntu Apache wsgi web.py 404找不到
我按照以上说明:http://webpy.org/cookbook/mod_wsgi-apache-ubuntu
Apache的000-default.conf:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
WSGIScriptAlias /api /var/www/html/webpy-app/code.py
AddType text/html .py
...
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo
Order allow,deny
allow from all
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
</Directory>
</VirtualHost>
code.py,给出了一个404错误:
import web
urls = (
'/.*', 'hello',
)
class hello:
def GET(self):
return "Hello, world."
application = web.application(urls, globals()).wsgifunc()
WSGI工作时,例如在,如果我把下列code.py,它的工作原理(从http://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html#embedded-or-daemon-mode拍摄):
import sys
def application(environ, start_response):
status = '200 OK'
output = u'wsgi.multithread = %s' % repr(environ['wsgi.multithread'])
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output.encode('UTF-8')]
摆脱mod_python。你不应该使用它,它会干扰mod_wsgi的正常运行,这就是为什么你需要添加它。 –