Web2Py on AWS EC2

462 views
Skip to first unread message

NeoToren

unread,
Jan 2, 2015, 6:38:25 PM1/2/15
to web...@googlegroups.com
I have an instance running Linux at Amazon AWS EC2 after carefully following the instructions provided by Amazon here.
I have set-up the security groups as mentioned in the documentation provided by Amazon.

The default security group has all traffic, all protocols, on all ports open.

In addition to the above security rule, I have setup SSH on port 22 and then, using CyberDuck (a great FTP app), I have uploaded the Web2Py source code into a folder named web2py at AWS.
After successfully FTP the source code into this web2py folder, I have SSH'ed into the AWS machine using the Terminal (on Mac locally) having the my-keys-file.pem on hand:


(where the xx are the numbers in the Public DNS as they appear on my instance on EC2 page)

Then I have checked whether my AWS instance has python installed and it does have it (v2.6.9).
Thus, I have proceeded to install Web2Py.

python2.6 web2py.py
password = pwd
it warns that GUI is not available since Tlk library is not installed, but Massimo says here that it's not critical.

Running the Web2Py ....
1. If I try:

python web2py.py -a pwd -i 0.0.0.0 -p 80

It says: there is an error with the Rocket Server with that specific port (used by another process that is not willing to share...)

2. Tried without mentioning the port:

python web2py.py -a pwd

it says nothing (which begs the question: is web2py running ?) and when I try to access the web2py server
or
https://ec2-xx-xx-xx-xxx.compute-1.amazonaws.com/admin
in both cases it says page is not available since it takes too long to access it (nothing about security cause).

3. If I try:

python web2py.py -a pwd -i 0.0.0.0 -p 8000

again - it says nothing (is web2py running ?)
trying to access the Web2Py server at
http://ec2-xx-xx-xx-xxx.compute-1.amazonaws.com/ 
or
https://ec2-xx-xx-xx-xxx.compute-1.amazonaws.com/admin
in both cases it says page is not available, same as above.

4. I have tried to use the IP address instead, but it is immediately translated to the amazon format of ec2-xx-xx-xx-xxx.etc...
5. Tried to access the web2py, while explicitly mentioning the port (like http://ec2-xx-xx-xx-xxx.compute-1.amazonaws.com:8000/  - still it does not work, without mentioning the reason (except the page is not available)

My questions:
1. Is there any DETAILED recipe on how to install AND run Web2Py on AWS EC2 ? I couldn't find anything and the one recipe Massimo provided for AWS EC2 on Ubuntu a couple of years ago - didn't help.
2. Is the web2py server running ? How can I know if it is running ? If it is not - what am I doing incorrectly ?
3. If the web2py server is running how can I access it ?

Any help would be much appreciated.
Thanks

Niphlod

unread,
Jan 3, 2015, 11:07:17 AM1/3/15
to web...@googlegroups.com
AWS EC2 is nothing more of a linux server . to start executables listening on port 80 superuser permissions are needed, only "high ports" are allowed at "normal user" powers (that's why on production one usually deploys web2py BEHIND a real webserver).
Enough of that said, starting with

python web2py.py -a mypwd

should print out exactly what prints out in any platform, which is

web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2015
Version x.x.x.......
Database drivers available: ................
blablabla

if that doesn't come out, it's hardly a web2py issue...check in another terminal with top (or htop) if the process is running or if there is anything else going on.

NeoToren

unread,
Jan 3, 2015, 11:41:18 AM1/3/15
to web...@googlegroups.com
My apologies Niphlod,

1. I didn't mention that the result of the command ...  python web2py.py -a mypwd ... is actually :

web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2015
Version 2.9.11-stable+timestamp.2014.09.15.23.35.11
Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(pg8000), IMAP(imaplib)
please visit:
use "kill -SIGTERM 27150" to shutdown the web2py server

2. Being (very) new to Linux, I don't know much about nix, top , htop, etc, and I am just following recipes... blindly.
With that being said - is web2py running on my Linux AWS EC2 instance ? If so - how to access it ?

Many thanks
NeoToren

Niphlod

unread,
Jan 4, 2015, 12:42:42 PM1/4/15
to web...@googlegroups.com
ok. this is documented in the book, but to sum it up, when you start web2py.py without the -i parameter by default it binds only to localhost (meaning it's accessible only from the same host it's running, in your case, the EC2 instance). if you want to reach it to http://theipaddress_ofec2instance:8000 all you have to do is to start it with

web2py.py -i 0.0.0.0 -a mypwd

0.0.0.0 is a "meta-address" that means "listen on all interfaces".

NeoToren

unread,
Jan 4, 2015, 4:11:01 PM1/4/15
to web...@googlegroups.com
Must be something really simple (and stupid on my behalf) that I am doing or not doing correctly...

While in the web2py folder on the AWS instance, I've run web2py by trying both specifying the port and without it:
1. python web2py.py -i 0.0.0.0 -a mypwd
2. python web2py.py -i 0.0.0.0 -a mypwd -p 8000

In both cases it replies with the usual:
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2015
Version 2.9.11-stable+timestamp.2014.09.15.23.35.11
Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(pg8000), IMAP(imaplib)
please visit:
use "kill -SIGTERM 27150" to shutdown the web2py server

Which I take as "the web2py server is up and running"

Tried to access web2py server at:
(where the xx are the numbers in the Public DNS as they appear on my instance on EC2 page)


3. xx.xx.xx.xx/ and with the port specified xx.xx.xx.xx:8000/
the actual IP address numbers...

4. https://ec2-xx-xx-xx-xx.compute-1.amazonaws.com/admin/default/index with or without port...

Just doesn't work.
Eventually the browser says it takes too long to load page so page doesn't exist or cannot be accessed.





Niphlod

unread,
Jan 5, 2015, 3:12:43 PM1/5/15
to web...@googlegroups.com
maybe the the linux vm has a firewall on port 8000........ by default security groups aren't configured for port 8000. if you're using the "vanilla" amazon ec2 instance, see the related documents on http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html#adding-security-group-rule

BTW:  with or without the explicit -p 8000 it will only listen to port 8000, so don't even try to reach it from http://xxx.xxx.xxxx/: you need to use ALWAYS http://xxx.xxx.xxxxxxx:8000/ .

btw2: if you're not skilled in system administration and you don't want to learn there are far better environments to deploy web2py which will take care of the administrative side of things. If instead you want to learn something on the process, see the bazillions guides around the internet ^_^
Reply all
Reply to author
Forward
0 new messages