Python apache2 mod_wsgi瓶装名称错误:名称';操作系统&x27;没有定义
我正在尝试使用apache2 mod_wsgi来部署瓶子.py web应用程序 我遵照以下指示: 添加了一个文件/var/www/yourapp/app.wsgi:Python apache2 mod_wsgi瓶装名称错误:名称';操作系统&x27;没有定义,python,apache,mod-wsgi,bottle,Python,Apache,Mod Wsgi,Bottle,我正在尝试使用apache2 mod_wsgi来部署瓶子.py web应用程序 我遵照以下指示: 添加了一个文件/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 app
# 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()
我将yourapp.py文件添加到/var/www/yourapp/:
from bottle import route, run, template
@route('/hello/:name')
def index(name='World'):
return template('<b>Hello {{name}}</b>!', name=name)
您需要将导入操作系统作为第一个文件(app.wsgi)的第一行。您正在尝试使用
os
模块,但没有首先导入它。我得到了以下信息:抱歉,请求的URL“”导致了一个错误:找不到:'/hello',这是因为您需要/hello/:name
,并且只输入'/hello'
[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