web.py'你好,世界'示例在Ubuntu 14.04上的Apache上出现404错误:"在此服务器上找不到请求的URL / api /。"
我按照这些说明操作:http://webpy.org/cookbook/mod_wsgi-apache-ubuntu
Apache 000-default.conf:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
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')]
答案 0 :(得分:0)
啊 - 通过添加修复:
<Files code.py>
SetHandler wsgi-script
Options ExecCGI FollowSymLinks
</Files>
到Apache 000-default.conf,我在http://webpy.org/install#apache
找到了