Deploying Bottle App with AWS

1.3k views Asked by At

I wanted to know how to deploy a app developed using bottle framework in AWS.

I created a EC2 instance, deployed the app in an environment - Linux Python 2.7 64 bit. I have the main file as application.py and run the framework using bottle.run(host='0.0.0.0")

I get following exception (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

Can let me know where I'm going wrong.

1

There are 1 answers

0
Wan B. On

As far as I now, you need to root access to bind to port 80. Try running it with

sudo ./application.py

Or you can change your port number to 8080 or similar.

If you are deploying this for production, I would suggest reading more on the bottlepy docs:

http://bottlepy.org/docs/dev/deployment.html#server-options

Hope it helps. Cheers.