2017-06-17 1 views
0

web.py 'Hello、world'の例では、Ubuntu 14.04のApacheで404エラーが表示されます。「要求されたURL/api /がこのサーバーに見つかりませんでした。Ubuntu Apache wsgi web.py 404が見つかりません

Iの手順に従った:http://webpy.org/cookbook/mod_wsgi-apache-ubuntu

アパッチ000-は、default.conf:404エラーを与える

<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:

import web 

urls = (
    '/.*', 'hello', 
    ) 

class hello: 
    def GET(self): 
     return "Hello, world." 

application = web.application(urls, globals()).wsgifunc() 

をWSGIは、例えば、動作しています私は(http://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html#embedded-or-daemon-modeから取られた)、それが動作code.pyに次のように置く場合:

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

ああ - 追加することによって固定:

<Files code.py> 
    SetHandler wsgi-script 
    Options ExecCGI FollowSymLinks 
</Files> 

を私が見つけたApacheの000-は、default.confにon http://webpy.org/install#apache

+0

mod_pythonを削除します。あなたはそれを使用すべきではありません。それはmod_wsgiの通常の動作を妨害します。なぜそれを追加する必要があったのですか? –

関連する問題