【发布时间】:2014-10-17 09:32:41
【问题描述】:
httpd.conf
Listen 8081
NameVirtualHost *:8081
<VirtualHost *:8081>
ServerName ubuntu.com
WSGIDaemonProcess kenobi user=www-data group=www-data processes=1 threads=5
WSGIScriptAlias / /var/www/kenobi/app.wsgi
<Directory /var/www/kenobi>
WSGIProcessGroup kenobi
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
app.wsgi
import os, sys
# Change working directory so relative paths (and template lookup) work again
sys.path.append('/var/www/kenobi')
os.chdir(os.path.dirname(__file__))
print sys.path
import server
print "launching..."
application = server.launch()
print "done"
server.py(使用bottle框架实现rest api的脚本)
@route('/helloworld', method='GET')
def get_service_host_list():
return("hello world")
def launch():
print "attaching to server"
run(host="192.168.45.111", port="8085", debug=True)
#application = bottle.default_app()
所以上面的代码工作正常,除了它使用两个端口 - 8081 被 mod_wsgi 用来启动 server.py 和 server.py 监听的 8085 端口
我需要在 server.py 中进行哪些更改以便只使用端口 8081? 我已经尝试过使用 application = bottle.default_app() 但每当我调用“helloworld”api 时,我都会在 apache2 error.log 中收到“500 Internal Server Error”和以下错误:
[Sat Aug 23 12:05:17 2014] [error] launching...
[Sat Aug 23 12:05:17 2014] [error] attaching to server
[Sat Aug 23 12:05:17 2014] [error] done
[Sat Aug 23 12:05:17 2014] [error] [client 192.168.42.135] mod_wsgi (pid=35700): Exception occurred processing WSGI script '/var/www/kenobi/app.wsgi'.
[Sat Aug 23 12:05:17 2014] [error] [client 192.168.42.135] TypeError: 'NoneType' object is not callable
求救!!!
【问题讨论】:
标签: python django apache mod-wsgi bottle