我想知道如何部署在AWS中使用瓶子框架开发的应用程序。
我创建了一个EC2实例,在一个环境中部署了应用程序 - Linux Python 2.7 64位。我将主文件作为application.py并使用bottle.run运行框架(host =' 0.0.0.0")
我得到以下异常(error.log)
[Sun Jun 14 16:15:08.989733 2015] [:error] [pid 2400] mod_wsgi (pid=2400): Target WSGI script '/opt/python/current/app/application.py' cannot be loaded as Python module.
[Sun Jun 14 16:15:08.989884 2015] [:error] [pid 2400] mod_wsgi (pid=2400): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Sun Jun 14 16:15:08.989922 2015] [:error] [pid 2400] Traceback (most recent call last):
[Sun Jun 14 16:15:08.989954 2015] [:error] [pid 2400] File "/opt/python/current/app/application.py", line 31, in <module>
[Sun Jun 14 16:15:08.990035 2015] [:error] [pid 2400] bottle.run(host='0.0.0.0', port=80)
[Sun Jun 14 16:15:08.990059 2015] [:error] [pid 2400] File "/opt/python/run/venv/lib/python2.7/site-packages/bottle.py", line 3117, in run
[Sun Jun 14 16:15:08.990094 2015] [:error] [pid 2400] server.run(app)
[Sun Jun 14 16:15:08.990114 2015] [:error] [pid 2400] File "/opt/python/run/venv/lib/python2.7/site-packages/bottle.py", line 2771, in run
[Sun Jun 14 16:15:08.990144 2015] [:error] [pid 2400] srv = make_server(self.host, self.port, app, server_cls, handler_cls)
[Sun Jun 14 16:15:08.990164 2015] [:error] [pid 2400] File "/usr/lib64/python2.7/wsgiref/simple_server.py", line 151, in make_server
[Sun Jun 14 16:15:08.990197 2015] [:error] [pid 2400] server = server_class((host, port), handler_class)
[Sun Jun 14 16:15:08.990217 2015] [:error] [pid 2400] File "/usr/lib64/python2.7/SocketServer.py", line 420, in __init__
[Sun Jun 14 16:15:08.990250 2015] [:error] [pid 2400] self.server_bind()
[Sun Jun 14 16:15:08.990271 2015] [:error] [pid 2400] File "/usr/lib64/python2.7/wsgiref/simple_server.py", line 48, in server_bind
[Sun Jun 14 16:15:08.990299 2015] [:error] [pid 2400] HTTPServer.server_bind(self)
[Sun Jun 14 16:15:08.990319 2015] [:error] [pid 2400] File "/usr/lib64/python2.7/BaseHTTPServer.py", line 108, in server_bind
[Sun Jun 14 16:15:08.990347 2015] [:error] [pid 2400] SocketServer.TCPServer.server_bind(self)
[Sun Jun 14 16:15:08.990367 2015] [:error] [pid 2400] File "/usr/lib64/python2.7/SocketServer.py", line 434, in server_bind
[Sun Jun 14 16:15:08.990394 2015] [:error] [pid 2400] self.socket.bind(self.server_address)
[Sun Jun 14 16:15:08.990414 2015] [:error] [pid 2400] File "/usr/lib64/python2.7/socket.py", line 224, in meth
[Sun Jun 14 16:15:08.990442 2015] [:error] [pid 2400] return getattr(self._sock,name)(*args)
[Sun Jun 14 16:15:08.990475 2015] [:error] [pid 2400] error: [Errno 13] Permission denied
可以让我知道我哪里出错了。
答案 0 :(得分:1)
就我而言,您需要root访问权限绑定到端口80。 尝试使用
运行它sudo ./application.py
或者您可以将端口号更改为8080或类似。
如果您要将其部署用于生产,我建议您阅读有关瓶装文档的更多内容:
http://bottlepy.org/docs/dev/deployment.html#server-options
希望它有所帮助。 欢呼声。