我正在尝试使用 apache2 mod_wsgi 来部署 bottle.py Web 应用程序。
我按照以下说明进行操作:
http://bottlepy.org/docs/dev/deployment.html#apache-mod-wsgi
添加了一个文件 /var/www/yourapp/app.wsgi:
# Change working directory so relative paths (and template lookup) work again
os.chdir(os.path.dirname(__file__))
import bottle
# ... build or import your bottle application here ...
# Do NOT use bottle.run() with mod_wsgi
application = bottle.default_app()
我在 /var/www/yourapp/ 中添加了一个 yourapp.py 文件:
from bottle import route, run, template
@route('/hello/:name')
def index(name='World'):
return template('<b>Hello {{name}}</b>!', name=name)
我在做正确的事吗?
我收到一个 Http 500 错误,并在日志中发现了一些错误:
[Fri Feb 22 15:03:38 2013] [error] [client 192.168.0.104] os.chdir(os.path.dirname(__file__))
[Fri Feb 22 15:03:38 2013] [error] [client 192.168.0.104] NameError: name 'os' is not defined
ke@dslds /var/log/apache2 $ NameError: name 'os' is not definedNameError: name 'os' is not defined